Guest User

Untitled

a guest
Sep 25th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. This is to propose using P-Strings (Pascal-Strings) as the standard string format.
  2.  
  3. === Benefits of using P-Strings ===
  4. * Accessing the length of the string is O(1) fast.
  5. * Buffer overflows are prevented by being able to allocate enough space ahead of time.
  6. ** This also decreases the risk of code injection into the program.
  7. * 0 can be used in strings, while a 0 in C-Strings would terminate the string.
  8. * Concat for P-Strings is O(n). Concat for C-Strings is O(n+m)
  9.  
  10. === Disadvantages of using P-Strings ===
  11. * Indexing would begin at 1, instead of the conventional 0
  12. * Even on fixed-length fields, the first byte would be needed for the length
  13.  
  14. === Other notes ===
  15. * Having a limit of 255 chars for a string is reasonable for the DCPU. Therefore, P-Strings are no more expensive than C-Strings.
  16. * Cutting off the beginning of a string is more expensive for P-Strings, but cutting off the end is more expensive for C-Strings. Therefore, those two arguments negate each other.
  17.  
  18. The advantages of P-String outweigh the disadvantages. Therefore, I propose to use P-Strings as the String Format Standard.
Add Comment
Please, Sign In to add comment