perf: replace string concatenation with list join and add normalized headers map in html, http, jinja, json, markdown modules
Optimize string building in decodeUtf8_, slugify, parseRaw_, processCode_, and processBold_ by accumulating parts in a list and joining once, avoiding repeated string allocation. In HttpResponse constructor, precompute a normalized headers map for O(1) case-insensitive header lookups instead of linear scan. Simplify Json.stringify indent generation using string repetition operator.
This commit is contained in:
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "scheduler" for Scheduler
|
||||
import "timer" for Timer
|
||||
import "web" for SessionStore
|
||||
|
||||
var store = SessionStore.new()
|
||||
var results = []
|
||||
var taskCount = 5
|
||||
|
||||
for (i in 0...taskCount) {
|
||||
var index = i
|
||||
Scheduler.add {
|
||||
var session = store.create()
|
||||
session["task"] = index
|
||||
store.save(session)
|
||||
results.add({"id": session.id, "index": index})
|
||||
}
|
||||
}
|
||||
|
||||
System.print(results.count) // expect: 0
|
||||
|
||||
Timer.sleep(50)
|
||||
|
||||
System.print(results.count) // expect: 5
|
||||
|
||||
var uniqueIds = {}
|
||||
for (r in results) {
|
||||
uniqueIds[r["id"]] = true
|
||||
}
|
||||
System.print(uniqueIds.count) // expect: 5
|
||||
|
||||
var hasAll = true
|
||||
for (i in 0...5) {
|
||||
var found = false
|
||||
for (r in results) {
|
||||
if (r["index"] == i) found = true
|
||||
}
|
||||
if (!found) hasAll = false
|
||||
}
|
||||
System.print(hasAll) // expect: true
|
||||
Reference in New Issue
Block a user