A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/protocolbuffers/protobuf/commit/b968d0daa86158039de22887e4ac3914b77ea4b0 below:

fix bug in Map.hash · protocolbuffers/protobuf@b968d0d · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+20

-4

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+20

-4

lines changed Original file line number Diff line number Diff line change

@@ -650,8 +650,8 @@ VALUE Map_hash(VALUE _self) {

650 650

TypeInfo key_info = {self->key_type};

651 651

upb_MessageValue key, val;

652 652

while (upb_Map_Next(self->map, &key, &val, &iter)) {

653 -

hash = Msgval_GetHash(key, key_info, hash);

654 -

hash = Msgval_GetHash(val, self->value_type_info, hash);

653 +

hash += Msgval_GetHash(key, key_info, 0);

654 +

hash += Msgval_GetHash(val, self->value_type_info, 0);

655 655

}

656 656 657 657

return LL2NUM(hash);

Original file line number Diff line number Diff line change

@@ -232,8 +232,8 @@ def ==(other)

232 232

def hash

233 233

return_value = 0

234 234

each_msg_val do |key_message_value, value_message_value|

235 -

return_value = Google::Protobuf::FFI.message_value_hash(key_message_value, key_type, nil, return_value)

236 -

return_value = Google::Protobuf::FFI.message_value_hash(value_message_value, value_type, descriptor, return_value)

235 +

return_value += Google::Protobuf::FFI.message_value_hash(key_message_value, key_type, nil, 0)

236 +

return_value += Google::Protobuf::FFI.message_value_hash(value_message_value, value_type, descriptor, 0)

237 237

end

238 238

return_value

239 239

end

Original file line number Diff line number Diff line change

@@ -416,6 +416,22 @@ def test_map_basic

416 416

end

417 417

end

418 418 419 +

# This is a regression test for a bug in Map.hash. It used to return an

420 +

# inconsistent result when there was a collision in the map (two keys mapping

421 +

# to the same hash table entry).

422 +

def test_map_hash

423 +

for i in 0..25

424 +

for j in i+1..25

425 +

m = Google::Protobuf::Map.new(:int32, :string)

426 +

m[i] = "abc"

427 +

m[j] = "def"

428 +

m2 = m.dup

429 +

assert_equal m, m2

430 +

assert_equal m.hash, m2.hash

431 +

end

432 +

end

433 +

end

434 + 419 435

def test_b_8385

420 436

m1 = Google::Protobuf::Map.new(:string, :string)

421 437

m2 = Google::Protobuf::Map.new(:string, :string)

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4