Recent

Author Topic: Stange behaviour of Lazarus Trunk version  (Read 7770 times)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11637
  • FPC developer.
Re: Stange behaviour of Lazarus Trunk version
« Reply #90 on: June 13, 2024, 05:28:06 pm »
All this because of not being able to determine the string length?

What's wrong with the #0 at the end of the string as a length?

  • getting length is a O(n) operation instead of O(1)
  •   what if it is not there? - additional mitigation necessary for security reasons (-n- versions). For automated types, this upperbound must be stored somewhere ... better store length in the first place
  • #0 becomes a forbidden character.
  • No automated copy-on-write


Quote
Last time I checked most DB engines were written in languages that used NUL char at the end of a string.

Bug, not feature  ;)
« Last Edit: June 13, 2024, 05:35:36 pm by marcov »

Thaddy

  • Hero Member
  • *****
  • Posts: 15120
  • Censorship about opinions does not belong here.
Re: Stange behaviour of Lazarus Trunk version
« Reply #91 on: June 13, 2024, 05:34:18 pm »
Totally agree.
Running strlen as opposed to reading the length of a string from the string record is very much slower. The length is stored at negative offset for pascal strings.
Pascal string types do not need to crawl over every single char to obtain the length.
Of course the national anthem of the U.S.A. was written by Jimi Hendrix, didn't you know that?

 

TinyPortal © 2005-2018