Hacker News new | past | comments | ask | show | jobs | submit login

This all comes down to design decisions on a higher level - why arent your elements fixed-size? Why are you using delimiters at all, instead of a [size|content][size|content] kind of layout? You dont need the delimiter if you know, for each element, how big it is, which also tells you where the next one starts. No more magic delimiters, and no find, substring until, etc.



> You dont need the delimiter if you know, for each element, how big it is

Do you seriously propose writing something like

    2,7Sdata2,3Cfoo2,3Cbar2,4C12343,11Chello world2,7Cgoodbye2,7Chunter23,26Cswordfish is a red herring
instead of

    data: string[7] = {
        "foo",
        "bar",
        "1234",
        "hello world",
        "goodbye",
        "hunter2",
        "swordfish is a red herring",
    }
? Thanks but no thanks, almost nobody likes to write Bencode by hand, just trust me.


No, I mean binary, so you read size of each element in BINARY, which, as you should know, means you dont need a single delimiter anywhere.


And the size of the size is supposed to be fixed? By how much? 1 byte? 8 bytes?




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: