Re: RFC: SBuf::find api

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Mon, 25 Mar 2013 14:35:17 +1300

On 25/03/2013 5:35 a.m., Kinkie wrote:
> Hi all,
> digging up some documentation for the inconsistent behavior of
> std::string::find() in GCC, it appears that its behavior is undefined
> if the pos parameter is std::string::npos.
> I'd like to define that behavior by making it explicit in the API that
> SBuf::find (in any variant) when called with pos=SBuf::npos will
> return SBuf::npos. This is consistent with recent gcc, but not with
> the current implementation
>
> Any comments?

I think it would be a good thing to do.

One other thing that struck me was that we could possibly leverage npos
being a large integer value to optimize some of the special case tests
as pos>length() as all returning npos. It was not possible to do when
making our API exactly match std::string i the fuzzing probably because
it hit these inconsistencies.

Amos
Received on Mon Mar 25 2013 - 01:35:24 MDT

This archive was generated by hypermail 2.2.0 : Mon Mar 25 2013 - 12:00:09 MDT