Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You never need to call strlen unless you are getting your inputs from a place that doesn’t give you a string length (such as stdin).


So which is it, then? Does keeping size separate "blows your CPU cache"¹ or not? You can't argue it does in one case (Rust) but not in your case…

(And note that the representation you're responding to is not really a "header", in the same sense that the trailing null is a "footer". The representation does not require the length be contiguous with the data, but that's what upthread was trying to say in the first place.)

¹(it doesn't…)


So now you are arguing that by default your strings should come with a length? Great!

If you want that, you might as well bake that length into the string type by default (and use a specialised type, perhaps a naked raw pointer into the string) for when you don't want to pass the length.


That's most interfaces…?


Not argv[].


You still need to call strlen on each element?




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

Search: