@@ -1053,6 +1053,13 @@ rb_enc_check(VALUE str1, VALUE str2)
1053
1053
static rb_encoding *
1054
1054
enc_compatible_latter (VALUE str1 , VALUE str2 , int idx1 , int idx2 )
1055
1055
{
1056
+ if (idx1 < 0 || idx2 < 0 )
1057
+ return 0 ;
1058
+
1059
+ if (idx1 == idx2 ) {
1060
+ return rb_enc_from_index (idx1 );
1061
+ }
1062
+
1056
1063
int isstr1 , isstr2 ;
1057
1064
rb_encoding * enc1 = rb_enc_from_index (idx1 );
1058
1065
rb_encoding * enc2 = rb_enc_from_index (idx2 );
@@ -1111,15 +1118,7 @@ enc_compatible_str(VALUE str1, VALUE str2)
1111
1118
int idx1 = enc_get_index_str (str1 );
1112
1119
int idx2 = enc_get_index_str (str2 );
1113
1120
1114
- if (idx1 < 0 || idx2 < 0 )
1115
- return 0 ;
1116
-
1117
- if (idx1 == idx2 ) {
1118
- return rb_enc_from_index (idx1 );
1119
- }
1120
- else {
1121
- return enc_compatible_latter (str1 , str2 , idx1 , idx2 );
1122
- }
1121
+ return enc_compatible_latter (str1 , str2 , idx1 , idx2 );
1123
1122
}
1124
1123
1125
1124
rb_encoding *
@@ -1128,13 +1127,6 @@ rb_enc_compatible(VALUE str1, VALUE str2)
1128
1127
int idx1 = rb_enc_get_index (str1 );
1129
1128
int idx2 = rb_enc_get_index (str2 );
1130
1129
1131
- if (idx1 < 0 || idx2 < 0 )
1132
- return 0 ;
1133
-
1134
- if (idx1 == idx2 ) {
1135
- return rb_enc_from_index (idx1 );
1136
- }
1137
-
1138
1130
return enc_compatible_latter (str1 , str2 , idx1 , idx2 );
1139
1131
}
1140
1132
0 commit comments