aboutsummaryrefslogtreecommitdiffstats
path: root/benchmark
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-01 13:44:49 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-01 13:44:49 +0000
commiteda7f9fa129cdaad0aed6b2ace65a192f26ab9fa (patch)
tree47399c3fb76ba2ca3d2f729f3f6452fe63acbf0b /benchmark
parent7268ff1ac82ee70293478f45204c0446f29c1209 (diff)
downloadruby-eda7f9fa129cdaad0aed6b2ace65a192f26ab9fa.tar.gz
string.c: avoid unnecessary call of str_strlen()
* string.c (rb_strseq_index): refactor and avoid call of str_strlen() when offset == 0. it will improve performance of String#index and #include? * benchmark/bm_string_index.rb: benchmark for this change git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/bm_string_index.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/benchmark/bm_string_index.rb b/benchmark/bm_string_index.rb
new file mode 100644
index 0000000000..7783111082
--- /dev/null
+++ b/benchmark/bm_string_index.rb
@@ -0,0 +1,3 @@
+str1 = "あ" * 1024 + "い" # not single byte optimizable
+str2 = "い"
+100_000.times { str1.index(str2) }