nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4b52524
)
lib/standard: redef a fast path for `HashMap#get_or_null`
author
Jean Privat
<jean@pryen.org>
Tue, 3 Feb 2015 13:53:05 +0000
(20:53 +0700)
committer
Jean Privat
<jean@pryen.org>
Tue, 3 Feb 2015 13:53:05 +0000
(20:53 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>
lib/standard/collection/hash_collection.nit
patch
|
blob
|
history
diff --git
a/lib/standard/collection/hash_collection.nit
b/lib/standard/collection/hash_collection.nit
index
f4f218e
..
b62d876
100644
(file)
--- a/
lib/standard/collection/hash_collection.nit
+++ b/
lib/standard/collection/hash_collection.nit
@@
-235,6
+235,16
@@
class HashMap[K, V]
end
end
+ redef fun get_or_null(key)
+ do
+ var c = node_at(key)
+ if c == null then
+ return null
+ else
+ return c._value
+ end
+ end
+
redef fun iterator: HashMapIterator[K, V] do return new HashMapIterator[K,V](self)
redef fun length do return _the_length