Cache call to size() in find(): it wasn't being optimized out.

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@1000 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
jfbastien 2009-03-05 21:12:02 +00:00
parent 2d56e06cff
commit a34780ce1e

View file

@ -896,9 +896,10 @@ public:
size_type find (const value_type* s, size_type pos, size_type n) const size_type find (const value_type* s, size_type pos, size_type n) const
{ {
if (n + pos > size()) const size_type size(size());
if (n + pos > size)
return npos; return npos;
for (; pos + n <= size(); ++pos) for (; pos + n <= size; ++pos)
{ {
if (traits_type::compare(data() + pos, s, n) == 0) if (traits_type::compare(data() + pos, s, n) == 0)
{ {