Files
Nim/lib/system
metagn 839cbeb371 js: replace push.apply with for loop for string add [backport] (#25267)
While `a.push.apply(a, b)` is better for performance than the previous
`a = a.concat(b)` due to the fact that it doesn't create a new array,
there is a pretty big problem with it: depending on the JS engine, if
the second array is too long, it can [cause a
crash](https://tanaikech.github.io/2020/04/20/limitation-of-array.prototype.push.apply-under-v8-for-google-apps-script/)
due to the function `push` taking too many arguments. This has
unfortunately been what the codegen produces since 1.4.0 (commit
707367e1ca).

So string addition is now moved to a compilerproc that just uses a `for`
loop. From what I can tell this is the most compatible and the fastest.
Only potential problem compared to `concat` etc is with aliasing, i.e.
adding an array to itself, but I'm guessing it's enough that the length
from before the iteration is used, since it can only grow. The test
checks for aliased nim strings but I don't know if there's an extra
protection for them.
2025-11-07 20:19:50 +08:00
..
2025-11-06 17:33:52 +01:00
2025-05-16 09:44:13 +02:00
2025-10-28 12:48:22 +01:00
2025-10-28 12:48:22 +01:00
2023-11-06 07:57:29 +01:00
2024-08-11 10:35:09 +08:00
2020-01-30 10:54:50 +01:00