This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] improve string find algorithm
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Aditya Kumar <aditya dot k7 at samsung dot com>
- Cc: "'Jonathan Wakely'" <jwakely at redhat dot com>, libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org, hiraditya at msn dot com
- Date: Fri, 6 Jan 2017 16:09:28 +0100
- Subject: Re: [PATCH] improve string find algorithm
- Authentication-results: sourceware.org; auth=none
- References: <1481132816-31162-1-git-send-email-aditya.k7@samsung.com> <CGME20170106133507epcas2p15eaabe5ca279349c9f3603a6c2bb61d8@epcas2p1.samsung.com> <20170106133502.GB2966@redhat.com> <016101d2682b$136dc890$3a4959b0$@samsung.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Jan 06, 2017 at 08:42:15AM -0600, Aditya Kumar wrote:
> Yes, we do.
> Sorry for the mistake, it happened because I first wrote this for
> libcxx (https://reviews.llvm.org/D27068) and while porting that line
> got missed.
Shouldn't find at least in the case where it is narrow char string
just use C library memmem? That implements a Two-Way searching algorithm
with some improvements from Boyer-Moore.
Otherwise, consider what even your modified version will do for
#include <string>
int main() {
(std::string(10000000, 'a')+"b").find(std::string(1000000, 'a')+"b");
}
Or does the C++ library need to reinvent everything implemented in the C
library?
Jakub