"belltown" wrote:
Yes, len() counts the chars, one by one. So it probably indexes that way too, and maybe does store UTF-8 chars as contiguous bytes internally.
And that is what it does, of course:
BrightScript Debugger> tm.mark(): _ = mid(s, n/2, 1): ? tm.TotalMilliseconds()
84
BrightScript Debugger> tm.mark(): _ = mid(s2, n/2, 1): ? tm.TotalMilliseconds()
300
The (-) side: string operations in B/S take O(n) instead of O(1) time. Disturbing realization, never seen that before.
The (+) side: strings have compact representation in memory.