| ▲ | GalaxyNova 6 hours ago | |||||||
Yes I have seen it happen a few times with `strlen` being called in a loop silently causing O(N) to turn to O(N^2) | ||||||||
| ▲ | jkrejcha 5 hours ago | parent | next [-] | |||||||
Reminds me of an article[1] that described how he cut GTA Online loading times by 70% because strlen was getting called for effectively every character in a string [1]: https://nee.lv/2021/02/28/How-I-cut-GTA-Online-loading-times... | ||||||||
| ||||||||
| ▲ | senfiaj 6 hours ago | parent | prev | next [-] | |||||||
Exactly, you can't write clean concise code when working with c strings. Almost every c string manipulation requires cognitive load: "Is the buffer size enough (including null terminator), should I reallocate it?", "I need to have the offset from the last concat, to make next concats performant", "Umm, shold I put null terminator at i or i + 1?"... It really sucks, it's akin to death by thousands of cuts. | ||||||||
| ▲ | sgerenser 4 hours ago | parent | prev [-] | |||||||
Joel Spolsky coined the term “Shlemiel the Painter’s Algorithm” for this type of thing back in 2001: https://www.joelonsoftware.com/2001/12/11/back-to-basics/ | ||||||||