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. Linux:grep命令详解

    grep grep(global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具, ...

  2. SQL 动态PIVOT查询

    DECLARE @sql_str VARCHAR(8000)DECLARE @sql_col VARCHAR(8000) SELECT @sql_col = ISNULL(@sql_col + ',' ...

  3. 在初次安vs2008时设置的为C#现在怎么将其改为其他类型的界面

    如将C#改成C++, 工具 -> 导入和导出设置 -> 重置所有设置 -> 否,仅重置设置,从而覆盖我的当前设置 -> 重新选一个设置 -> 完成 选择完毕后,如新建MF ...

  4. tomcat是否有必要配置环境变量

    之前发表了一篇关于如何安装和配置Tomcat的文章,而最近在开发项目的时候总是报错.后来被公司的大神问了一句:是谁告诉你Tomcat是需要配置环境变量的? 作为新手的我瞬间整个人都不好了!于是偷偷百度 ...

  5. CF 382C

    http://codeforces.com/problemset/problem/382/C 读完题立刻知道怎么做,然后分类讨论到吐血,写挂了,巨蠢 #include <iostream> ...

  6. .pyc和.pyo文件有何用

    百度知道:http://zhidao.baidu.com/link?url=_tFP1xglFnoEBObWtIArI3b3Ft0PQowx5m5ruIaX3mFIAFVr7vX45Lfb0geCjA ...

  7. 内联汇编实现 memcpy 和 memset

    #pragma check_stack( off) LPVOID __cdecl _memcpy(void * dst, void* src, size_t size) { int dwSize = ...

  8. 每天一个linux命令(文件操作):【转载】find命令之xargs

    在使用 find命令的-exec选项处理匹配到的文件时, find命令将所有匹配到的文件一起传递给exec执行.但有些系统对能够传递给exec的命令长度有限制,这样在find命令运行几分钟之后,就会出 ...

  9. BZOJ2705 SDOI2012 Longge的问题 【欧拉函数】

    BZOJ2705 SDOI2012 Longge的问题 Description Longge的数学成绩非常好,并且他非常乐于挑战高难度的数学问题.现在问题来了:给定一个整数N,你需要求出∑gcd(i, ...

  10. NET Core项目模板

    打造自己的.NET Core项目模板 https://www.cnblogs.com/catcher1994/p/10061470.html 前言 每个人都有自己习惯的项目结构,有人的喜欢在项目里面建 ...