Skip to content

Commit f174f6e

Browse files
committed
utf8_to_uv_msgs: Hoist common paradigm out of switch()
Instead of initializing this to 0 and then setting it in each case of the switch, initialize it to the most common value, remove those statements that set it to that, leaving the rest alone.
1 parent 79c191f commit f174f6e

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

utf8.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
19331933

19341934
while (possible_problems) { /* Handle each possible problem */
19351935
char * message = NULL;
1936-
U32 this_flag_bit = 0;
19371936

19381937
/* Each 'case' handles one problem given by a bit in
19391938
* 'possible_problems'. The lowest bit positions, as #defined in
@@ -1945,6 +1944,9 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
19451944
* it changes 'uv' looked at by the others */
19461945

19471946
U32 this_problem = 1U << lsbit_pos32(possible_problems);
1947+
1948+
U32 this_flag_bit = this_problem;
1949+
19481950
possible_problems &= ~this_problem;
19491951

19501952
/* Most case:s use this; overridden in a few */
@@ -1971,7 +1973,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
19711973
if (NEED_MESSAGE(WARN_UTF8,,)) {
19721974
message = Perl_form(aTHX_ "%s (empty string)",
19731975
malformed_text);
1974-
this_flag_bit = UTF8_GOT_EMPTY;
19751976
}
19761977
}
19771978

@@ -1988,7 +1989,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
19881989
" with no preceding start byte)",
19891990
malformed_text,
19901991
_byte_dump_string(s0, 1, 0), *s0);
1991-
this_flag_bit = UTF8_GOT_CONTINUATION;
19921992
}
19931993
}
19941994

@@ -2008,7 +2008,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
20082008
(int)avail_len,
20092009
avail_len == 1 ? "" : "s",
20102010
(int)expectlen);
2011-
this_flag_bit = UTF8_GOT_SHORT;
20122011
}
20132012
}
20142013

@@ -2033,7 +2032,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
20332032
printlen,
20342033
s - s0,
20352034
(int) expectlen));
2036-
this_flag_bit = UTF8_GOT_NON_CONTINUATION;
20372035
}
20382036
}
20392037

@@ -2058,7 +2056,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
20582056
else {
20592057
message = Perl_form(aTHX_ surrogate_cp_format, uv);
20602058
}
2061-
this_flag_bit = UTF8_GOT_SURROGATE;
20622059
}
20632060
}
20642061

@@ -2082,7 +2079,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
20822079

20832080
pack_warn = packWARN(WARN_NONCHAR);
20842081
message = Perl_form(aTHX_ nonchar_cp_format, uv);
2085-
this_flag_bit = UTF8_GOT_NONCHAR;
20862082
}
20872083
}
20882084

@@ -2151,7 +2147,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
21512147
small code points */
21522148
UNI_TO_NATIVE(uv));
21532149
}
2154-
this_flag_bit = UTF8_GOT_LONG;
21552150
}
21562151
}
21572152

@@ -2204,7 +2199,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
22042199
message = Perl_form(aTHX_ "%s: %s (overflows)",
22052200
malformed_text,
22062201
_byte_dump_string(s0, curlen, 0));
2207-
this_flag_bit = UTF8_GOT_OVERFLOW;
22082202
}
22092203
}
22102204

@@ -2228,7 +2222,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
22282222
else {
22292223
message = Perl_form(aTHX_ super_cp_format, uv);
22302224
}
2231-
this_flag_bit = UTF8_GOT_SUPER;
22322225
}
22332226
}
22342227

@@ -2288,8 +2281,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
22882281
* this iteration of the loop */
22892282
if (message) {
22902283
if (msgs) {
2291-
assert(this_flag_bit);
2292-
22932284
if (*msgs == NULL) {
22942285
*msgs = newAV();
22952286
}

0 commit comments

Comments
 (0)