56 points · by christophilus · 4y ago · 14 comments
When I have strings on performance-critical paths, unless they’re too long for a good reason, I sometimes pad them with \0 and limiting them to 16- or 32-bytes length. This way I can pass strings in a vector register by value (i.e. __m128i or __m256i data type in C++), and they’re very efficient to deal with. For instance, comparing them for equality only takes two instructions, vpxor and vptest (_mm_xor_si128 and _mm_testz_si128 intrinsics for 16-byte vectors), that’s 3-4 cycles of latency, an order of magnitude better than comparing traditional C or C++ strings.
I don’t have any experience with dlang though, not sure how easy or hard to implement that in D.
https://github.com/dlang-community/awesome-d
If you insist dissecting existing code, the Hunt library is well commented and seems more approachable. It uses OOP and some templates.
Anyway D is a good language. It pays my bills.
You take from D what you bring. If you basically want to write C++ with nicer OOP you can, if you want to write heavy-metaprogramming functional code then you can as well.
The only thing I would say is that D is a language that does take a little programming experience to really appreciate.
> Woke companies
Having met people from most D companies I'm not sure I know what you mean.