Skip to content

Commit 0d5e145

Browse files
committed
Refactor StringDomain to use ResettableLazy
1 parent a230618 commit 0d5e145

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/cdomains/stringDomain.ml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@ let name () = "string"
44

55
type string_domain = Unit | Disjoint | Flat
66

7-
let string_domain = ref None
7+
let string_domain: string_domain ResettableLazy.t =
8+
ResettableLazy.from_fun (fun () ->
9+
match GobConfig.get_string "ana.base.strings.domain" with
10+
| "unit" -> Unit
11+
| "disjoint" -> Disjoint
12+
| "flat" -> Flat
13+
| _ -> failwith "ana.base.strings.domain: illegal value"
14+
)
815

9-
let string_domain_config = "ana.base.strings.domain"
10-
11-
let parse config = match config with
12-
| "unit" -> Unit
13-
| "disjoint" -> Disjoint
14-
| "flat" -> Flat
15-
| _ -> raise @@ GobConfig.ConfigError ("Invalid option for " ^ string_domain_config)
16-
17-
let get_string_domain () =
18-
if !string_domain = None then
19-
string_domain := Some (parse (GobConfig.get_string string_domain_config));
20-
Option.get !string_domain
16+
let get_string_domain () = ResettableLazy.force string_domain
2117

2218
let reset_lazy () =
23-
string_domain := None
19+
ResettableLazy.reset string_domain
20+
2421

2522
type t = string option [@@deriving eq, ord, hash]
2623

0 commit comments

Comments
 (0)