(xpath: String)
| 932 | |
| 933 | impl<'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 { |
nothing calls this directly
no test coverage detected