From a74b83e3f275e44f686066081c7fdb665180ff9e Mon Sep 17 00:00:00 2001 From: Oskar Haarklou Veileborg Date: Thu, 12 Jan 2023 10:22:46 +0100 Subject: sets & maps: remove varargs APIs & SetMany variants The implementation behind the API is not more efficient than manually looping over a data structure and inserting elements one-by-one. --- immutable.go | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'immutable.go') diff --git a/immutable.go b/immutable.go index 4a42e33..e43bc70 100644 --- a/immutable.go +++ b/immutable.go @@ -752,17 +752,6 @@ func (m *Map[K, V]) Set(key K, value V) *Map[K, V] { return m.set(key, value, false) } -// SetMany returns a map with the keys set to the new values. nil values are allowed. -// -// This function will return a new map even if the updated value is the same as -// the existing value because Map does not track value equality. -func (m *Map[K, V]) SetMany(entries map[K]V) *Map[K, V] { - for k, v := range entries { - m = m.Set(k, v) - } - return m -} - func (m *Map[K, V]) set(key K, value V, mutable bool) *Map[K, V] { // Set a hasher on the first value if one does not already exist. hasher := m.hasher @@ -1641,14 +1630,6 @@ func (m *SortedMap[K, V]) Set(key K, value V) *SortedMap[K, V] { return m.set(key, value, false) } -// SetMany returns a map with the keys set to the new values. -func (m *SortedMap[K, V]) SetMany(entries map[K]V) *SortedMap[K, V] { - for k, v := range entries { - m = m.Set(k, v) - } - return m -} - func (m *SortedMap[K, V]) set(key K, value V, mutable bool) *SortedMap[K, V] { // Set a comparer on the first value if one does not already exist. comparer := m.comparer -- cgit v1.2.3