mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 17:50:02 +00:00
`token` on a string copied everything left in the string before scanning one object, and `search` and `anchorsearch` copied both strings before comparing them. A program that walks a string by what each call leaves copied the rest of it on every call. All three now read the strings in place and release the borrow before the scanned object is checked against the budget and before the results are pushed. Results, errors and the operations charged against the budget are the same as before. Walking a 512 KiB string takes 16 ms instead of 518 ms with `token` and 1.0 ms instead of 27 ms with `search` (release build on Linux under load from other builds, median of 7 alternating runs); on a 4 KiB string the difference is under 0.1 ms. Tests in tests_strings.rs compare each operator with the copying code on the same operands (stack, error and operations left after every call), check that the results see later writes to the string, and check that no string is copied.