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
+42
@@ -0,0 +1,42 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "scheduler" for Scheduler
|
||||
import "timer" for Timer
|
||||
|
||||
var results = []
|
||||
var completed = 0
|
||||
|
||||
Scheduler.add {
|
||||
results.add("fiber1_start")
|
||||
Timer.sleep(1)
|
||||
results.add("fiber1_end")
|
||||
completed = completed + 1
|
||||
}
|
||||
|
||||
Scheduler.add {
|
||||
results.add("fiber2_start")
|
||||
Timer.sleep(1)
|
||||
results.add("fiber2_end")
|
||||
completed = completed + 1
|
||||
}
|
||||
|
||||
Scheduler.add {
|
||||
results.add("fiber3_start")
|
||||
Timer.sleep(1)
|
||||
results.add("fiber3_end")
|
||||
completed = completed + 1
|
||||
}
|
||||
|
||||
System.print(completed) // expect: 0
|
||||
System.print(results.count) // expect: 0
|
||||
|
||||
Timer.sleep(10)
|
||||
|
||||
System.print(completed) // expect: 3
|
||||
System.print(results.count) // expect: 6
|
||||
System.print(results.contains("fiber1_start")) // expect: true
|
||||
System.print(results.contains("fiber1_end")) // expect: true
|
||||
System.print(results.contains("fiber2_start")) // expect: true
|
||||
System.print(results.contains("fiber2_end")) // expect: true
|
||||
System.print(results.contains("fiber3_start")) // expect: true
|
||||
System.print(results.contains("fiber3_end")) // expect: true
|
||||
Reference in New Issue
Block a user