Module: Riak::Util::String
- Included in:
- Bucket, BucketType, Crdt::HyperLogLog, Crdt::Set
- Defined in:
- lib/riak/util/string.rb
Overview
Methods comparing strings
Class Method Summary collapse
Class Method Details
.equal_bytes?(a, b) ⇒ Boolean
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/riak/util/string.rb', line 5 def equal_bytes?(a, b) return true if a.nil? && b.nil? return false unless a.respond_to?(:bytesize) return false unless b.respond_to?(:bytesize) return false unless a.bytesize == b.bytesize return false unless a.respond_to?(:bytes) return false unless b.respond_to?(:bytes) b1 = a.bytes.to_a b2 = b.bytes.to_a i = 0 loop do c1 = b1[i] c2 = b2[i] return false unless c1 == c2 i += 1 break if i > b1.length end true end |