Skip to content

Commit

Permalink
[Truffle] Pulled in String#sum from Rubinius.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Mar 11, 2015
1 parent 25a64b4 commit 3d5ad3f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/string/sum_tags.txt

This file was deleted.

13 changes: 13 additions & 0 deletions truffle/src/main/ruby/core/rubinius/common/string.rb
Expand Up @@ -97,6 +97,19 @@ def slice!(one, two=undefined)
result
end

def sum(bits=16)
bits = Rubinius::Type.coerce_to bits, Fixnum, :to_int
i = -1
sum = 0

sum += @data[i] while (i += 1) < @num_bytes
if bits > 0
sum & ((1 << bits) - 1)
else
sum
end
end

def to_c
Complexifier.new(self).convert
end
Expand Down

0 comments on commit 3d5ad3f

Please sign in to comment.