Short-circuit operator== based on size()
authorTom Jackson <tjackson@fb.com>
Wed, 13 Mar 2013 22:44:59 +0000 (15:44 -0700)
committerJordan DeLong <jdelong@fb.com>
Tue, 19 Mar 2013 00:09:22 +0000 (17:09 -0700)
commitdf1ffef33a788d14089e7fad2ee6cb84d192504b
treeaea867614f95747fbfce822670ce9aea069265d5
parent76d60885da567e2ae9e4cc454bb8eefe869f8943
Short-circuit operator== based on size()

Summary:
We don't do this today, but it looks like std::string does. For longer, similar strings, this is a big win.

Before:

```lang=text
============================================================================
./folly/test/FBStringTestBenchmarks.cpp.h       relative  time/iter  iters/s
============================================================================
BM_equality_string(65536)                                    5.13ms   194.87
BM_equality_fbstring(65536)                                 11.34ms    88.18
============================================================================
```

After:

```lang=text
============================================================================
./folly/test/FBStringTestBenchmarks.cpp.h       relative  time/iter  iters/s
============================================================================
BM_equality_string(65536)                                    5.01ms   199.74
BM_equality_fbstring(65536)                                  6.63ms   150.78
============================================================================
```

Test Plan: Benchmark, unit  tests

Reviewed By: tudorb@fb.com

FB internal diff: D737482
folly/FBString.h
folly/test/FBStringBenchmark.cpp
folly/test/FBStringTestBenchmarks.cpp.h