Checking if a string is null

Regan Heath regan at netmail.co.nz
Thu Jul 26 01:20:10 PDT 2007


Derek Parnell wrote:
> On Wed, 25 Jul 2007 14:29:47 +0100, Regan Heath wrote:
> 
>> Aside: If the location and length are identical you can short-circuit 
>> the compare, returning true and ignoring the content, this could save a 
>> bit of time on comparisons of large arrays.
> 
> I don't think this is such a good idea. How does one address the array of
> four bytes at RAM location 4?


What I meant was:

if (lhs.length == rhs.length && lhs.ptr == rhs.ptr) return true;

Not:

if (lhs.length == lhs.ptr) return true;

;)

Regan


More information about the Digitalmars-d-learn mailing list