From: Nicholas Clark Date: Fri, 19 May 2006 16:31:35 +0000 (+0000) Subject: strlen(foo) rather than strchr(foo, 0) makes simpler code, and is X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f8225f8afdb4886e3a792f44a7d91c93463cbb78;p=p5sagit%2Fp5-mst-13.2.git strlen(foo) rather than strchr(foo, 0) makes simpler code, and is likely to be a more efficient implementation. p4raw-id: //depot/perl@28236 --- diff --git a/perlio.c b/perlio.c index a0cb4a4..a4b7bb4 100644 --- a/perlio.c +++ b/perlio.c @@ -1423,11 +1423,11 @@ PerlIO_context_layers(pTHX_ const char *mode) type = SvPV_const(layers, len); if (type && mode[0] != 'r') { /* - * Skip to write part + * Skip to write part, which is separated by a '\0' */ - const char * const s = strchr(type, 0); - if (s && (STRLEN)(s - type) < len) { - type = s + 1; + STRLEN read_len = strlen(type); + if (read_len < len) { + type += read_len + 1; } } }