[QualifiedName] Don't compute regex in each of_qual_string call

Reviewed By: jberdine

Differential Revision: D4843262

fbshipit-source-id: 246692c
master
Andrzej Kotulski 8 years ago committed by Facebook Github Bot
parent b956d2ddef
commit 2214034d03

@ -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<bar::baz<goo>>::someMethod" will get parsed as ["foo<bar", "baz<goo>>",
"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;

Loading…
Cancel
Save