Use raise_notrace instead of raise to implement Hashtbl.replace.
This significantly improves the benchmark below: let ht = Hashtbl.create 100 in for x = 1 to 2500000 do Hashtbl.replace ht x (); Hashtbl.remove ht x done (about 20% faster, still not as good as #328, which is about 35% faster than trunk on this one) In addition to the speedup, using raise_notrace should avoid destroying the current stack trace when Hashtbl.replace is used in an exception handler.master
parent
1c9e418b92
commit
66e864a53f
|
@ -158,7 +158,7 @@ let find_all h key =
|
||||||
let replace h key info =
|
let replace h key info =
|
||||||
let rec replace_bucket = function
|
let rec replace_bucket = function
|
||||||
| Empty ->
|
| Empty ->
|
||||||
raise Not_found
|
raise_notrace Not_found
|
||||||
| Cons(k, i, next) ->
|
| Cons(k, i, next) ->
|
||||||
if compare k key = 0
|
if compare k key = 0
|
||||||
then Cons(key, info, next)
|
then Cons(key, info, next)
|
||||||
|
@ -350,7 +350,7 @@ module MakeSeeded(H: SeededHashedType): (SeededS with type key = H.t) =
|
||||||
let replace h key info =
|
let replace h key info =
|
||||||
let rec replace_bucket = function
|
let rec replace_bucket = function
|
||||||
| Empty ->
|
| Empty ->
|
||||||
raise Not_found
|
raise_notrace Not_found
|
||||||
| Cons(k, i, next) ->
|
| Cons(k, i, next) ->
|
||||||
if H.equal k key
|
if H.equal k key
|
||||||
then Cons(key, info, next)
|
then Cons(key, info, next)
|
||||||
|
|
Loading…
Reference in New Issue