Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

14
  • 6
    Huh? What "fast pointer operations" don't work with length prefixing? More importantly, other languages which use length prefixing are faster than C w.r.t. string manipulation. Commented Dec 11, 2010 at 20:23
  • 13
    @billy: With length prefixed strings, you can't just take a string pointer and add 4 to it, and expect it to still be a valid string, because it doesn't have a length prefix (not a valid anyway). Commented Dec 11, 2010 at 20:30
  • 3
    @j_random_hacker: Concatenation is much worse for asciiz strings (O(m+n) instead of potentially O(n)), and concat is much more common than any of the other operations listed here. Commented Dec 11, 2010 at 21:00
  • 3
    there's one tiiny little operation that becomes more expensive with null-terminated strings: strlen. I'd say that's a bit of a drawback. Commented Dec 11, 2010 at 21:10
  • 12
    @Billy ONeal: everyone else also support regex. So what ? Use libraries that's what they are made for. C is about maximal efficiency and minimalism, not batteries included. C tools also allow you to implement Length Prefixed string using structs very easily. And nothing forbids you to implement the string manipulation programs through managing your own length and char buffers. That's usually what I do when I want efficiency and use C, not calling a handful of functions that expect a zero at the end of a char buffer is not a problem. Commented Dec 12, 2010 at 0:24