hamstergem/hamster — pull request #151 by dubek (2014-10-30 16:45:52+00:00)
Title: Trie#put, Trie#bulk_put: return self if value is not changed

Modify `Trie#put` and `Trie#bulk_put` so they don't create a new `Trie` instance if the value being stored is identical (same Ruby object_id) to the value that already appears in the receiver.

This allows the nice behaviour in which `Hash#merge` and `Set#union` simply return self when merging with a subset Hash/Set (and of course same for `Hash#put` and `Hash#store`).

One thing that requires extra care: I changed `Hash#store` to simply call `Hash#put` (to avoid code duplication). However, maybe we *do* want to have the duplication to allow people to subclass `Hamster::Hash` and modify `put`'s behaviour without affecting `store`'s behaviour??

BTW - if this is accepted I'm considering similar change for `Vector`.