Merge: Optimize get_or_null
authorJean Privat <jean@pryen.org>
Wed, 4 Feb 2015 08:38:06 +0000 (15:38 +0700)
committerJean Privat <jean@pryen.org>
Wed, 4 Feb 2015 08:38:06 +0000 (15:38 +0700)
commitd81bebe888398b9aa34152e7a86deafd83d12014
tree5fe0418fefe53142c2a7ec2d87ba38d9a829d242
parenta525b056c5f6e1cc2822e195ff89d9c9a8a3102a
parent0492ae4e6afef42c5accc23927734f93181b1e69
Merge: Optimize get_or_null

Recent profiling of the interpreter nit shows that a lof of time is used in hashmaps. This PR improves the standard use-path with the safe method `get_or_null` that is more efficient (and simple) than `has_key` followed by `[]`.

The time for `nit doors_with_classes.nit 5000` give

before: 0m5.592s
after: 0m5.208s (-6,7%)

Note: by comparison, the ruby version is 0m2.284s, and the python is 0m0.116s ; there is still a lot of work

Pull-Request: #1139
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>