(function: &BNFunction)
| 29 | pub static PLAT_MATCHER_CACHE: OnceLock<DashMap<PlatformID, Matcher>> = OnceLock::new(); |
| 30 | |
| 31 | pub fn cached_function_matcher(function: &BNFunction) { |
| 32 | let platform = function.platform(); |
| 33 | let platform_id = PlatformID::from(platform.as_ref()); |
| 34 | let matcher_cache = PLAT_MATCHER_CACHE.get_or_init(Default::default); |
| 35 | match matcher_cache.get(&platform_id) { |
| 36 | Some(matcher) => matcher.match_function(function), |
| 37 | None => { |
| 38 | let matcher = Matcher::from_platform(platform); |
| 39 | matcher.match_function(function); |
| 40 | matcher_cache.insert(platform_id, matcher); |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | // TODO: Maybe just clear individual platforms? This works well enough either way. |
| 46 | pub fn invalidate_function_matcher_cache() { |
no test coverage detected