Skip to content

Commit

Permalink
Fix hashmap construction (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreypfau committed Feb 10, 2023
1 parent 95ff4ff commit 3c240c6
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ public sealed interface HashMapE<T> : Iterable<Pair<BitString, T>>, TlbObject {
public fun <T> fromMap(map: Map<BitString, T>?): HashMapE<T> {
var hashMap = empty<T>()
if (map == null) return hashMap
var i = -1
map.forEach { (key, value) ->
require(!key.isEmpty()) { "Empty key" }
if (i == -1) i = key.size
else require(i == key.size) { "Variable length key, expected: $i, actual: (${key.size}) $key" }
hashMap = hashMap.set(key, value)
}
return hashMap
Expand Down
Loading

0 comments on commit 3c240c6

Please sign in to comment.