News for hackers. Stuff that matters.
Re:Sentinels Can Be Faster by pornel on Thursday September 10, 2020 @08:21AM (#24431580)
I really like Rust's approach of keeping string length in the pointer.

It allows making substrings without copying (and there's no costly substring gotcha you get in GC languages, because the borrow checker will loudly remind you when you try to keep the substring longer than the original string).

In string-processing algorithms the length usually stays in a register, so (unlike Pascal string approach) it doesn't contribute to on-heap cost of the string. Knowing length ahead of time allows having SIMD-optimized loops.

There are no comments on this comment yet.