summaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/encoding.c b/encoding.c
index b64688e0f5..002c0c04fb 100644
--- a/encoding.c
+++ b/encoding.c
@@ -670,11 +670,11 @@ rb_enc_compatible(VALUE str1, VALUE str2)
enc1 = rb_enc_from_index(idx1);
enc2 = rb_enc_from_index(idx2);
+ if (TYPE(str2) == T_STRING && RSTRING_LEN(str2) == 0)
+ return enc1;
+ if (TYPE(str1) == T_STRING && RSTRING_LEN(str1) == 0)
+ return enc2;
if (!rb_enc_asciicompat(enc1) || !rb_enc_asciicompat(enc2)) {
- if (TYPE(str2) == T_STRING && RSTRING_LEN(str2) == 0)
- return enc1;
- if (TYPE(str1) == T_STRING && RSTRING_LEN(str1) == 0)
- return enc2;
return 0;
}