summaryrefslogtreecommitdiff
path: root/benchmark/bm_string_index.rb
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
commit8320be1007be68232580e374669f54232657dc73 (patch)
tree47399c3fb76ba2ca3d2f729f3f6452fe63acbf0b /benchmark/bm_string_index.rb
parent8875e0ca4affbe1c24ed7c13728124e58881061e (diff)
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/bm_string_index.rb')
-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) }