File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -35,15 +35,25 @@ let is_valid =
3535 len > 0 && loop s 0 len
3636;;
3737
38+ let table = String.Table. create 512
39+
40+ let make s =
41+ match String.Table. find table s with
42+ | Some s -> s
43+ | None ->
44+ String.Table. add_exn table s s;
45+ s
46+ ;;
47+
3848let of_string s =
3949 if is_valid s
40- then A s
50+ then A (make s)
4151 else Code_error. raise " Dune_lang.Atom.of_string got invalid atom" [ " atom" , String s ]
4252;;
4353
4454let to_string (A s ) = s
45- let parse s = if is_valid s then Some (A s ) else None
46- let of_int i = A (string_of_int i)
55+ let parse s = if is_valid s then Some (A (make s) ) else None
56+ let of_int i = A (make ( string_of_int i) )
4757let of_float x = of_string (string_of_float x)
48- let of_bool x = A (string_of_bool x)
58+ let of_bool x = A (make ( string_of_bool x) )
4959let of_int64 i = A (Int64. to_string i)
You can’t perform that action at this time.
0 commit comments