内存高效的C ++字符串(interning,ropes,copy-on-write等) [英] Memory-efficient C++ strings (interning, ropes, copy-on-write, etc)
本文介绍了内存高效的C ++字符串(interning,ropes,copy-on-write等)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序有内存问题,包括复制大量的字符串,使用相同的字符串作为许多哈希表中的键等。我正在寻找一个基类为我的字符串,使这非常高效。
My application is having memory problems, including copying lots of strings about, using the same strings as keys in lots of hashtables, etc. I'm looking for a base class for my strings that makes this very efficient.
我希望:
- String interning同样的内存),
- copy-on-write(我认为这在几乎所有std :: string实现中都是免费的),
我的平台在Linux上是g ++(但是这是
My platform is g++ on Linux (but that is unlikely to matter).
推荐答案
如果大多数字符串都是不可变的,则 Boost Flyweight 库可能适合您的需要。
If most of your strings are immutable, the Boost Flyweight library might suit your needs.
它会做字符串实习,但我不相信它是copy-on-write 。
It will do the string interning, but I don't believe it does copy-on-write.
这篇关于内存高效的C ++字符串(interning,ropes,copy-on-write等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文