4 ms·
Better String Library (2015)
- gnabgib 4y agoWouldn't https://github.com/websnarf/bstrlib https://github.com/websnarf/bstrlib be a better URL?
- deleted 4y ago[deleted]
- emmanueloga_ 4y agoYes :-)
- emmanueloga_ 4y agoSo we have: * https://en.wikipedia.org/wiki/String_(computer_science) https://en.wikipedia.org/wiki/String_(computer_science) -- * https://en.wikipedia.org/wiki/Rope_(data_structure) https://en.wikipedia.org/wiki/Rope_(data_structure) * https://hn.algolia.com/?query=Ropes%2C%20an%20Alternative%20to%20Strings https://hn.algolia.com/?query=Ropes%2C%20an%20Alternative%20... -- * https://en.wikipedia.org/wiki/Piece_table https://en.wikipedia.org/wiki/Piece_table * https://hn.algolia.com/?query=%22Piece%20Table%22 https://hn.algolia.com/?query=%22Piece%20Table%22 -- * https://en.wikipedia.org/wiki/Gap_buffer https://en.wikipedia.org/wiki/Gap_buffer * https://hn.algolia.com/?query=Gap%20Buffer https://hn.algolia.com/?query=Gap%20Buffer -- Anything else? Would be nice to implement all of these as a single library! What am I missing?
- asveikau 4y agoThis library is called bstrings, but Microsoft has BSTR/BStrings. Those are ucs-2/utf-16, zero terminated, with a length prefix. In Windows 8, someone at Microsoft decided they had too many string types, so they introduced another one (HSTRING).
- djbusby 4y agoIn VB/ASP3.0 (Windows 2000) the VB string concat was very slow and I built a small class to just make them concat faster (pre-allocated buffer). Sped up those Response.Write() like 40x. While writing it I was surprised by all the text vs binary crap Windows does.
- asveikau 4y agoI wonder if they used BSTR. Which was made for COM and OLE. Iirc vb and vbscript basically spoke COM. Each BSTR is on the COM heap, and they have just one length field, no notion of "capacity". So you don't get amortized constant time appends. The NT kernel had UNICODE_STRING which had a capacity. So many string types...
- deleted 4y ago[deleted]
- thurn 4y agoI believe this is the same string representation Rust uses? Although in Rust the empty string is guaranteed to not allocate memory, not sure if that's true here.
- ape4 4y agoSeems like asking for trouble to have the struct not opaque.
- waynecochran 4y agoNot sure why it mentions C++. C++ has std::string which is far superior to this.
- dan_hawkins 4y agoThat is true. I've used bstring before in my project and it's been at least a magnitude slower that std::string in basic operations (concatenation, replacement(s) and so on.)