Sha256: b681496e3f4173ab83e89481867e68a9759f0113ee5603e0db7c81c3ce897b5a

Contents?: true

Size: 710 Bytes

Versions: 3

Compression:

Stored size: 710 Bytes

Contents

module Riak
  module Util
    # Methods comparing strings
    module String
      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

      module_function :equal_bytes?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
riak-client-2.6.0 lib/riak/util/string.rb
riak-client-2.5.0 lib/riak/util/string.rb
riak-client-2.4.1 lib/riak/util/string.rb