• LalSalaamComradeOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    16 days ago

    What about data structures like gap buffer or piece table? Would they be ideal for something like, say, a TUI-interface application?

    • tunetardis@lemmy.ca
      link
      fedilink
      English
      arrow-up
      1
      ·
      16 days ago

      Oh, so you’re talking about text representation in an editor or something along those lines? That’s kind of a separate problem isn’t it?

      At the lowest level though, I suppose you still need to consider whether to use null-terminated segments. I think I’d still be going length + data, though I wouldn’t worry about packing down the length representation like with serialization formats. Your code will need to be highly cognizant of the length of strings and managing dynamic memory allocation all over the place, so it’s good to have those lengths quickly accessible at all times.