TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: C++11 immutable string

23 点作者 syvex将近 11 年前
I&#x27;m looking for feedback on this approach to an immutable string (istring). The idea is to provide a super fast immutable string that can be efficiently passed to lambdas as well as be 100% thread safe.<p>Another bonus is faster hashing. If a string literal is given to istring, then the hash is computed at compile time! Other strings will have their hashes cached for later use. The istring is designed more or less after the python string in this regard.<p>It should also consume less memory than std::string and perform faster in all other areas.

2 条评论

Nican将近 11 年前
Just as a note, on Java 7, developers opted for not having a single buffer backing multiple strings due to the backing references never been deleted. [1] [2]<p>[1] <a href="http://stackoverflow.com/questions/16123446/java-7-string-substring-complexity" rel="nofollow">http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;16123446&#x2F;java-7-string-su...</a><p>[2] <a href="http://www.reddit.com/r/programming/comments/1qw73v/til_oracle_changed_the_internal_string/" rel="nofollow">http:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;programming&#x2F;comments&#x2F;1qw73v&#x2F;til_orac...</a>
评论 #7844740 未加载
thegeomaster将近 11 年前
Great job. I like it how peole are moving to and developing for C++11 as I think it&#x27;s a huge step forward in the standard. The one cosmetic complaint I have is that the slicing syntax is not verbose enough for my taste. Also, what hash algo did you use? Asking just out of curiosity. I remember running a benchmark a long ago of different non-cryptographic hashes. The collision resistance was pretty consistent across all of them, but some were really slow and some were really fast, and that could directly affect the performance on hashtables and other structures that rely on hashes.
评论 #7845325 未加载
评论 #7845355 未加载