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. 简单说说什么是Restful

    在确定要把自己的服务创建成RESTFUL之前,要明白什么样的服务什么是RESTFUL service(https://en.wikipedia.org/wiki/Representational_st ...

  2. wampserver搭建本地服务器

    打开..\wamp\bin\apache\apache2.4.9\conf\httpd.conf配置文件, <Directory "c:/wamp/www/"> # # ...

  3. 【剑指offer】圆圈中最后剩下的数字(约瑟夫问题),C++实现

    原创博文,转载请注明出处! # 题目 # 思路 本题即为典型的约瑟夫问题,通过递推公式倒推出问题的解.原始问题是从n个人中每隔m个数踢出一个人,原始问题变成从n-1个人中每隔m个数踢出一个人--    ...

  4. MySQL存储引擎(engine:处理表的处理器)

    1.基本的操作命令: 1.查看所有存储引擎 show engines: 2.查看已有表的存储引擎: show create table 表名: 3.创建表指定的存储引擎 create table 表名 ...

  5. html 刷新 按钮 代码

    <input type=button value=刷新 onclick="history.go(0)"> <input type=button value=刷新 ...

  6. NSLayoutConstraint 布局,配合简单的动画效果

    demo地址 :链接: http://pan.baidu.com/s/1c00ipDQ 密码: mi4c 1 @interface ViewController () @property (nonat ...

  7. Eclipse中注释方法操作(两种)

    Eclipse 中的两种注释方法:(1)多行注释 /* */ (2)单行注释 // 多行注释操作方法. 选中注释部分-菜单栏右上角 source: Add block comment.必须选中需要注释 ...

  8. Java并发--进程与线程由来

    下面是本文的目录大纲: 一.操作系统中为什么会出现进程? 二.为什么会出现线程? 三.多线程并发 一.操作系统中为什么会出现进程? 说起进程的由来,我们需要从操作系统的发展历史谈起. 也许在今天,我们 ...

  9. HTML5移动Web开发指南-学习笔记(一)

    一,浏览器引擎    浏览器的内核引擎,基本上是四分天下: Trident: IE 以Trident 作为内核引擎; Gecko: Firefox 是基于 Gecko 开发; WebKit: Safa ...

  10. CALayer2-创建新的层

    本文目录 一.添加一个简单的图层 二.添加一个显示图片的图层 三.为什么CALayer中使用CGColorRef和CGImageRef这2种数据类型,而不用UIColor和UIImage? 四.UIV ...