Skip to content

Commit efff4c0

Browse files
committed
utf8_to_uv_msgs: Hoist common paradigm out of switch
Previously this variable was initialized to 0 and then set to another value in each case in the switch. But most of the cases set it to the same value. Might as well initialize it to that value, remove the statements that merely repeat that, and leave in the cases that set it to something else.
1 parent 5a82da7 commit efff4c0

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

utf8.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
19321932
((msgs) ? warning : 0))))
19331933

19341934
while (possible_problems) { /* Handle each possible problem */
1935-
U32 pack_warn = 0;
19361935
char * message = NULL;
19371936
U32 this_flag_bit = 0;
19381937

@@ -1948,6 +1947,9 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
19481947
U32 this_problem = 1U << lsbit_pos32(possible_problems);
19491948
possible_problems &= ~this_problem;
19501949

1950+
/* Most case:s use this; overridden in a few */
1951+
U32 pack_warn = packWARN(WARN_UTF8);
1952+
19511953
switch (this_problem) {
19521954
case UTF8_GOT_OVERFLOW:
19531955

@@ -2015,7 +2017,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
20152017

20162018
disallowed = TRUE;
20172019
if (NEED_MESSAGE(WARN_UTF8,,)) {
2018-
pack_warn = packWARN(WARN_UTF8);
20192020
message = Perl_form(aTHX_ "%s (empty string)",
20202021
malformed_text);
20212022
this_flag_bit = UTF8_GOT_EMPTY;
@@ -2030,7 +2031,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
20302031
if (! (flags & UTF8_ALLOW_CONTINUATION)) {
20312032
disallowed = TRUE;
20322033
if (NEED_MESSAGE(WARN_UTF8,,)) {
2033-
pack_warn = packWARN(WARN_UTF8);
20342034
message = Perl_form(aTHX_
20352035
"%s: %s (unexpected continuation byte 0x%02x,"
20362036
" with no preceding start byte)",
@@ -2049,7 +2049,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
20492049
if (! (flags & UTF8_ALLOW_SHORT)) {
20502050
disallowed = TRUE;
20512051
if (NEED_MESSAGE(WARN_UTF8,,)) {
2052-
pack_warn = packWARN(WARN_UTF8);
20532052
message = Perl_form(aTHX_
20542053
"%s: %s (too short; %d byte%s available, need %d)",
20552054
malformed_text,
@@ -2077,7 +2076,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
20772076
int printlen = (flags & UTF8_NO_CONFIDENCE_IN_CURLEN_)
20782077
? (int) (s - s0)
20792078
: (int) (send - s0);
2080-
pack_warn = packWARN(WARN_UTF8);
20812079
message = Perl_form(aTHX_ "%s",
20822080
unexpected_non_continuation_text(s0,
20832081
printlen,
@@ -2232,7 +2230,6 @@ Perl_utf8_to_uv_msgs_helper_(const U8 * const s0,
22322230
disallowed = TRUE;
22332231

22342232
if (NEED_MESSAGE(WARN_UTF8,,)) {
2235-
pack_warn = packWARN(WARN_UTF8);
22362233

22372234
/* These error types cause 'uv' to be something that
22382235
* isn't what was intended, so can't use it in the

0 commit comments

Comments
 (0)