summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-29 09:10:32 (GMT)
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-29 09:10:32 (GMT)
commit05b9b42918868a0a355a5cf9ce0d92baf4236328 (patch)
tree6ed8059cdc4d5ef94f8cc4b73510bdf581be3105 /string.c
parentf9ca636ae772bef04bb7f8ff7f899ad000f6c051 (diff)
* encoding.c (rb_enc_check_str): add for performance.
This function only accept T_STRING (and T_REGEXP). This patch improves performance of a tiny_segmenter benchmark (num=2) 2.54sec -> 2.42sec on my machine. https://github.com/chezou/TinySegmenter.jl/blob/master/benchmark/benchmark.rb * encoding.c: add ENC_DEBUG and ENC_ASSERT() macros. * internal.h: add a decl. of rb_enc_check_str(). * string.c (rb_str_plus): use rb_enc_check_str(). * string.c (rb_str_subpat_set): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/string.c b/string.c
index ec6a8eb..3a00896 100644
--- a/string.c
+++ b/string.c
@@ -1598,7 +1598,7 @@ rb_str_plus(VALUE str1, VALUE str2)
long len1, len2;
StringValue(str2);
- enc = rb_enc_check(str1, str2);
+ enc = rb_enc_check_str(str1, str2);
RSTRING_GETMEM(str1, ptr1, len1);
RSTRING_GETMEM(str2, ptr2, len2);
str3 = rb_str_new(0, len1+len2);
@@ -4072,7 +4072,7 @@ rb_str_subpat_set(VALUE str, VALUE re, VALUE backref, VALUE val)
end = END(nth);
len = end - start;
StringValue(val);
- enc = rb_enc_check(str, val);
+ enc = rb_enc_check_str(str, val);
rb_str_splice_0(str, start, len, val);
rb_enc_associate(str, enc);
}