-
Notifications
You must be signed in to change notification settings - Fork 195
Description
I love QuickJS. The latest releases even have ropes, which means that code like this is faster than O(N*N):
var result = ""
for (i in 0 until 1000000) {
result += "x"
}Unfortunately, the release we’ve shipped to millions of our customers doesn’t have ropes, and that’s both caused real performance problems, and risks future performance problems.
We’ve worked around this problem elsewhere by avoiding StringBuilder. For example Json.encodeToStringFast uses JSON.stringify() to create its strings.
But there’s some places where it’s super awkward to work around this. For example, Wire’s ByteArrayProtoReader32 calls the stdlib’s ByteArray.decodeToString() function, and that thing uses a StringBuilder that runs super slowly on our QuickJS. Wire’s calling the right API here, and even the stdlib is also not unreasonable by assuming strings’ performance characteristics.