Skip to content

Commit abecf2e

Browse files
committed
inline.h: Add 'const's; avoid hiding outer variable
This changes some formal parameters to be const, and avoids reusing the same variable name within an inner block, to avoid confusion
1 parent 11db6fe commit abecf2e

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

embed.fnc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,9 @@ AmnpdRP |bool |is_ascii_string|NN const U8* const s|const STRLEN len
741741
AmnpdRP |bool |is_invariant_string|NN const U8* const s|const STRLEN len
742742
AnpdD |STRLEN |is_utf8_char |NN const U8 *s
743743
Abmnpd |STRLEN |is_utf8_char_buf|NN const U8 *buf|NN const U8 *buf_end
744-
AnipdP |bool |is_utf8_string |NN const U8 *s|STRLEN len
745-
Anpdmb |bool |is_utf8_string_loc|NN const U8 *s|STRLEN len|NN const U8 **ep
746-
Anipd |bool |is_utf8_string_loclen|NN const U8 *s|STRLEN len|NULLOK const U8 **ep|NULLOK STRLEN *el
744+
AnipdP |bool |is_utf8_string |NN const U8 *s|const STRLEN len
745+
Anpdmb |bool |is_utf8_string_loc|NN const U8 *s|const STRLEN len|NN const U8 **ep
746+
Anipd |bool |is_utf8_string_loclen|NN const U8 *s|const STRLEN len|NULLOK const U8 **ep|NULLOK STRLEN *el
747747
AmndP |bool |is_utf8_valid_partial_char \
748748
|NN const U8 * const s|NN const U8 * const e
749749
AnidP |bool |is_utf8_valid_partial_char_flags \

inline.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ non-Unicode code points are allowed.
290290
PERL_STATIC_INLINE UV
291291
Perl_valid_utf8_to_uvchr(const U8 *s, STRLEN *retlen)
292292
{
293-
UV expectlen = UTF8SKIP(s);
293+
const UV expectlen = UTF8SKIP(s);
294294
const U8* send = s + expectlen;
295295
UV uv = *s;
296296

@@ -373,7 +373,7 @@ L</is_utf8_string_loc>().
373373
*/
374374

375375
PERL_STATIC_INLINE bool
376-
Perl_is_utf8_string(const U8 *s, STRLEN len)
376+
Perl_is_utf8_string(const U8 *s, const STRLEN len)
377377
{
378378
/* This is now marked pure in embed.fnc, because isUTF8_CHAR now is pure.
379379
* Be aware of possible changes to that */
@@ -384,11 +384,11 @@ Perl_is_utf8_string(const U8 *s, STRLEN len)
384384
PERL_ARGS_ASSERT_IS_UTF8_STRING;
385385

386386
while (x < send) {
387-
STRLEN len = isUTF8_CHAR(x, send);
388-
if (UNLIKELY(! len)) {
387+
const STRLEN cur_len = isUTF8_CHAR(x, send);
388+
if (UNLIKELY(! cur_len)) {
389389
return FALSE;
390390
}
391-
x += len;
391+
x += cur_len;
392392
}
393393

394394
return TRUE;
@@ -418,7 +418,7 @@ See also L</is_utf8_string_loc>() and L</is_utf8_string>().
418418
*/
419419

420420
PERL_STATIC_INLINE bool
421-
Perl_is_utf8_string_loclen(const U8 *s, STRLEN len, const U8 **ep, STRLEN *el)
421+
Perl_is_utf8_string_loclen(const U8 *s, const STRLEN len, const U8 **ep, STRLEN *el)
422422
{
423423
const U8* const send = s + (len ? len : strlen((const char *)s));
424424
const U8* x = s;
@@ -427,11 +427,11 @@ Perl_is_utf8_string_loclen(const U8 *s, STRLEN len, const U8 **ep, STRLEN *el)
427427
PERL_ARGS_ASSERT_IS_UTF8_STRING_LOCLEN;
428428

429429
while (x < send) {
430-
STRLEN len = isUTF8_CHAR(x, send);
431-
if (UNLIKELY(! len)) {
430+
const STRLEN cur_len = isUTF8_CHAR(x, send);
431+
if (UNLIKELY(! cur_len)) {
432432
break;
433433
}
434-
x += len;
434+
x += cur_len;
435435
outlen++;
436436
}
437437

proto.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,17 +1609,17 @@ PERL_CALLCONV bool Perl_is_utf8_space(pTHX_ const U8 *p)
16091609
#define PERL_ARGS_ASSERT_IS_UTF8_SPACE \
16101610
assert(p)
16111611

1612-
PERL_STATIC_INLINE bool Perl_is_utf8_string(const U8 *s, STRLEN len)
1612+
PERL_STATIC_INLINE bool Perl_is_utf8_string(const U8 *s, const STRLEN len)
16131613
__attribute__pure__;
16141614
#define PERL_ARGS_ASSERT_IS_UTF8_STRING \
16151615
assert(s)
16161616

16171617
#ifndef NO_MATHOMS
1618-
PERL_CALLCONV bool Perl_is_utf8_string_loc(const U8 *s, STRLEN len, const U8 **ep);
1618+
PERL_CALLCONV bool Perl_is_utf8_string_loc(const U8 *s, const STRLEN len, const U8 **ep);
16191619
#define PERL_ARGS_ASSERT_IS_UTF8_STRING_LOC \
16201620
assert(s); assert(ep)
16211621
#endif
1622-
PERL_STATIC_INLINE bool Perl_is_utf8_string_loclen(const U8 *s, STRLEN len, const U8 **ep, STRLEN *el);
1622+
PERL_STATIC_INLINE bool Perl_is_utf8_string_loclen(const U8 *s, const STRLEN len, const U8 **ep, STRLEN *el);
16231623
#define PERL_ARGS_ASSERT_IS_UTF8_STRING_LOCLEN \
16241624
assert(s)
16251625
PERL_CALLCONV bool Perl_is_utf8_upper(pTHX_ const U8 *p)

0 commit comments

Comments
 (0)