- Each string function must recalculate the string length. This is an extreme performance killer.
- The length should be stored before the string in the memory:
Code: Select all
Structure DynamicStringVariable stringLength.i *stringPointer EndStructure Structure FixedStringVariable stringLength.i string.c[0] EndStructure
Code: Select all
Define text$ = "Example string" Debug @text$ ; Prints the value of *stringPointer Debug PeekI(@text$ - SizeOf(Integer)) ; Prints the value of stringLength
StringBuilder are not the solution, because we want also read strings fast.