folly/FBString.h

fbstring is a drop-in replacement for std::string. The main benefit of fbstring is significantly increased performance on virtually all important primitives. This is achieved by using a three-tiered storage strategy and by cooperating with the memory allocator. In particular, fbstring is designed to detect use of jemalloc and cooperate with it to achieve significant improvements in speed and memory usage.

fbstring supports 32- and 64-bit and little- and big-endian architectures.

Storage strategies


  • Small strings (<= 23 chars) are stored in-situ without memory allocation.

  • Medium strings (24 - 255 chars) are stored in malloc-allocated memory and copied eagerly.

  • Large strings (> 255 chars) are stored in malloc-allocated memory and copied lazily.

Implementation highlights


  • 100% compatible with std::string.

  • Thread-safe reference counted copy-on-write for strings "large" strings (> 255 chars).

  • Uses malloc instead of allocators.

  • Jemalloc-friendly. fbstring automatically detects if application uses jemalloc and if so, significantly improves allocation strategy by using non-standard jemalloc extensions.

  • find() is implemented using simplified Boyer-Moore algorithm. Casual tests indicate a 30x speed improvement overstring::find() for successful searches and a 1.5x speed improvement for failed searches.

  • Offers conversions to and from std::string.

FBString的更多相关文章

  1. Folly解读(零) Fbstring—— 一个完美替代std::string的库

    string 常见的三种实现方式 eager copy COW SSO Fbstring 介绍 Storage strategies Implementation highlights Benchma ...

  2. 用#define来实现多份近似代码 - map,set中的应用

    在stl中map,set内部都是使用相同的红黑树实现,map对应模板参数key_type,mapped_type,而set对应模板参数没有mapped_type 两者都支持insert操作 pair& ...

  3. 转: 在创业公司使用C++

    from: http://oicwx.com/detail/827436 在创业公司使用C++ 2016-01-04开发资讯 James Perry和朋友创办了一家公司,主要是做基于云的OLAP多维数 ...

  4. issues about Facebook Login

    在学习The complete iOS 9 Developer Course - Build 18 Apps 中的Letture134-Facebook Login,需要整合(integrate)Pa ...

  5. Conv

    folly/Conv.h folly/Conv.h is a one-stop-shop for converting values across types. Its main features a ...

  6. DynamicConverter

    folly/DynamicConverter.h When dynamic objects contain data of a known type, it is sometimes useful t ...

  7. ProducerConsumerQueue

    folly/ProducerConsumerQueue.h The folly::ProducerConsumerQueue class is a one-producer one-consumer ...

  8. folly学习心得(转)

    原文地址:  https://www.cnblogs.com/Leo_wl/archive/2012/06/27/2566346.html   阅读目录 学习代码库的一般步骤 folly库的学习心得 ...

  9. Java UDP的简单实例以及知识点简述

    UDP的实现 Java中实现UDP协议的两个类,分别是DatagramPacket数据包类以及DatagramSocket套接字类. 其与TCP协议实现不同的是: UDP的套接字DatagramSoc ...

随机推荐

  1. 数据仓库(Data Warehouse)建设

    数据仓库初体验 数据库仓库架构以前弄的很简单:将各种源的数据统一汇聚到DW中,DW没有设计,只是将所有数据汇聚起来: ETL也很简单,只是将数据同步到DW中,只是遇到BUG时,处理一些错误数据,例如: ...

  2. 给SqlParameter参数指定或不指定:@变量标识符的区别是什么?

    对于sql语句中一个@的参数@au_id,在sqlParameter中,可以用@au_id,也可以用au_id. 要是bt点的,用两个@,你就不能随便省略@了. 对于sql语句 : select *  ...

  3. MB到片组的映射

    待分析 链接原文: http://blog.csdn.net/mr_phy/article/details/61638262

  4. 类加载器:ClassLoader与Class的区别

    1.类加载器 java字节码(类)的加载是由虚拟机来完成的,虚拟机把描述类的Class文件加载到内存,并对数据进行校验.解析和初始化,最终形成能被java虚拟机直接使用的java类型,这就是虚拟机的类 ...

  5. [置顶] Android 关于SP读取与存储正确打开方式?

    一.存储方式分类:SharedPreferences存储 二.SharedPreferences存储 1.特点 ①存储单一数据,例如数值,字符串,布尔 ②文件:/date/date/包名/shared ...

  6. 解决在django中应用keras模型时出现的ValueError("Tensor %s is not an element of this graph." % obj)问题

    用keras训练好模型,再在django初始化加载模型,这个过程没有问题,但是在调用到模型执行model.predict()的时候就报错: raise ValueError("Tensor ...

  7. UISegmentedControl字体大小,颜色,选中颜色,左边椭圆,右边直线的Button 解决之iOS开发之分段控制器UISegmentedControl

        NSArray *segmentedArray = [NSArrayarrayWithObjects:STR(@"Mynews"),STR(@"Systemmes ...

  8. ubuntu 搜狗输入法成功安装

    第一次成功安装这个破玩意,心里万分高兴啊! 几个条件: 1 ubuntu14.04 2 对的教程 参考文献:http://jingyan.baidu.com/article/ad310e80ae6d9 ...

  9. Java项目中使用Log4J

    Log4J下载 官网:http://logging.apache.org/log4j/ Log4J 1.2下载地址:http://logging.apache.org/log4j/1.2/downlo ...

  10. ZOJ3329One Person Game(循环型 数学期望)

    There is a very simple and interesting one-person game. You have 3 dice, namely Die1, Die2 and Die3. ...