ref: 7bda5b9dce103d6553f7a49d39c1664d03e1e200
parent: 7ef538ccbcd502a6fe960509c26bca568d94c6a7
author: Ori Bernstein <[email protected]>
date: Thu Jan 9 09:05:38 EST 2014
Add 'htgetv' function. Returns a value no matter what. A default value, if needed.
--- a/libstd/htab.myr
+++ b/libstd/htab.myr
@@ -21,6 +21,7 @@
generic htput : (ht : htab(@k, @v)#, k : @k, v : @v -> void)
generic htdel : (ht : htab(@k, @v)#, k : @k -> void)
generic htget : (ht : htab(@k, @v)#, k : @k -> option(@v))
+ generic htgetv : (ht : htab(@k, @v)#, k : @k, fallback : @v-> @v)
generic hthas : (ht : htab(@k, @v)#, k : @k -> bool)
generic htkeys : (ht : htab(@k, @v)# -> @k[:])
;;
@@ -163,6 +164,13 @@
match idx(ht, k)
| `Some i: -> `Some ht.vals[i]
| `None: -> `None
+ ;;
+}
+
+generic htgetv = {ht, k, v
+ match idx(ht, k)
+ | `Some i: -> ht.vals[i]
+ | `None: -> v
;;
}
--- a/myrbuild/myrbuild.c
+++ b/myrbuild/myrbuild.c
@@ -373,8 +373,6 @@
head = *nargs;
for (i = 0; i < nlibs; i++)
visit(args, nargs, head, g, libs[i], looped, marked);
- compiled = mkht(strhash, streq);
-
}
void linkobj(char **files, size_t nfiles)