MCPcopy Create free account
hub / github.com/daisy/MathCAT / new

Method new

src/speech.rs:934–955  ·  view source on GitHub ↗
(xpath: String)

Source from the content-addressed store, hash-verified

932
933impl<'r> MyXPath {
934 fn new(xpath: String) -> Result<MyXPath> {
935 return XPATH_CACHE.with( |cache| {
936 let mut cache = cache.borrow_mut();
937 return Ok(
938 match cache.get(&xpath) {
939 Some(compiled_xpath) => {
940 // unsafe{ XPATH_CACHE_HITS += 1;};
941 compiled_xpath.clone()
942 },
943 None => {
944 let new_xpath = MyXPath {
945 rc: Rc::new( RCMyXPath {
946 xpath: MyXPath::compile_xpath(&xpath)?,
947 string: xpath.clone()
948 })};
949 cache.insert(xpath.clone(), new_xpath.clone());
950 new_xpath
951 },
952 }
953 )
954 });
955 }
956
957 pub fn build(xpath: &Yaml) -> Result<MyXPath> {
958 let xpath = match xpath {

Callers

nothing calls this directly

Calls 7

read_definitions_fileFunction · 0.85
errors_to_stringFunction · 0.85
getMethod · 0.80
merge_prefsMethod · 0.80
is_emptyMethod · 0.80
get_definitions_fileMethod · 0.80
get_errorMethod · 0.45

Tested by

no test coverage detected