fix bug in FBString::find
authorPhilip Pronin <philipp@fb.com>
Wed, 10 Aug 2016 22:03:37 +0000 (15:03 -0700)
committerFacebook Github Bot 5 <facebook-github-bot-5-bot@fb.com>
Wed, 10 Aug 2016 22:08:37 +0000 (15:08 -0700)
commit28c41287ec1006bac2a465b0244deb1f00607bc0
tree207df1dc1fb7f424e6b1dc5d82d52f2a4204fd93
parentb62a976d20c5c5b186a9888a34e8557ee59f046d
fix bug in FBString::find

Summary:
Standard (21.4.7.2 / 1):

> Determines the lowest position xpos, if possible, such that both of the following conditions obtain:
- pos <= xpos and xpos + str.size() <= size();
- traits::eq(at(xpos+I), str.at(I)) for all elements I of the string controlled
by str.

The existing logic violates the first requirement for `str.size() == 0` by
unconditionally returning `pos`.

Reviewed By: ot, Gownta

Differential Revision: D3698862

fbshipit-source-id: 9622f1b99b259d2d81ae83795dff9cd94619c725
folly/FBString.h
folly/test/FBStringTest.cpp