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:
2026-01-26 09:59:07 +00:00
parent d9ec21a70d
commit 62b60cce36
26 changed files with 663 additions and 394 deletions
+46
View File
@@ -0,0 +1,46 @@
// retoor <retoor@molodetz.nl>
import "scheduler" for Scheduler
import "timer" for Timer
var results = []
var errors = []
var handleSafe = Fn.new { |task|
var fiber = Fiber.new {
task.call()
}
var error = fiber.try()
if (error != null) {
errors.add(error)
}
}
Scheduler.add {
handleSafe.call {
results.add("good1")
}
}
Scheduler.add {
handleSafe.call {
Fiber.abort("intentional error")
}
}
Scheduler.add {
handleSafe.call {
results.add("good2")
}
}
System.print(results.count) // expect: 0
System.print(errors.count) // expect: 0
Timer.sleep(10)
System.print(results.count) // expect: 2
System.print(errors.count) // expect: 1
System.print(results[0]) // expect: good1
System.print(results[1]) // expect: good2
System.print(errors[0]) // expect: intentional error