aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/string.c b/string.c
index c1366e834e..af03bc72db 100644
--- a/string.c
+++ b/string.c
@@ -131,11 +131,13 @@ VALUE rb_cSymbol;
#define STR_ENC_GET(str) rb_enc_from_index(ENCODING_GET(str))
+static int fstring_cmp(VALUE a, VALUE b);
+
static st_table* frozen_strings;
static const struct st_hash_type fstring_hash_type = {
- rb_str_cmp,
- rb_str_hash
+ fstring_cmp,
+ rb_str_hash,
};
VALUE
@@ -153,6 +155,16 @@ rb_fstring(VALUE str)
return str;
}
+static int
+fstring_cmp(VALUE a, VALUE b)
+{
+ int cmp = rb_str_hash_cmp(a, b);
+ if (cmp != 0) {
+ return cmp;
+ }
+ return ENCODING_GET(b) - ENCODING_GET(a);
+}
+
static inline int
single_byte_optimizable(VALUE str)
{