diff --git a/infer/src/IR/QualifiedCppName.re b/infer/src/IR/QualifiedCppName.re index cea97502d..ad5acf509 100644 --- a/infer/src/IR/QualifiedCppName.re +++ b/infer/src/IR/QualifiedCppName.re @@ -37,14 +37,13 @@ let of_rev_list = ident; let cpp_separator = "::"; +/* define [cpp_separator_regex] here to compute it once */ +let cpp_separator_regex = Str.regexp_string cpp_separator; + /* This is simplistic and will give the wrong answer in some cases, eg "foo>::someMethod" will get parsed as ["foo>", "someMethod"]. Avoid using it if possible */ -let of_qual_string str => { - let class_sep_regex = Str.regexp_string cpp_separator; - /* wait until here to define the function so that [class_sep_regex] is only computed once */ - Str.split class_sep_regex str |> List.rev -}; +let of_qual_string str => Str.split cpp_separator_regex str |> List.rev; let to_separated_string quals sep::sep => List.rev quals |> String.concat sep::sep;