mirror of
https://github.com/mandiant/capa.git
synced 2026-02-04 11:07:53 -08:00
remove Scopes LRU caching
This commit is contained in:
@@ -132,25 +132,6 @@ def redirecting_print_to_tqdm(disable_progress):
|
||||
inspect.builtins.print = old_print # type: ignore
|
||||
|
||||
|
||||
def weak_lru(maxsize=128, typed=False):
|
||||
"""
|
||||
LRU Cache decorator that keeps a weak reference to 'self'
|
||||
"""
|
||||
|
||||
def wrapper(func):
|
||||
@functools.lru_cache(maxsize, typed)
|
||||
def _func(_self, *args, **kwargs):
|
||||
return func(_self(), *args, **kwargs)
|
||||
|
||||
@functools.wraps(func)
|
||||
def inner(self, *args, **kwargs):
|
||||
return _func(weakref.ref(self), *args, **kwargs)
|
||||
|
||||
return inner
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def log_unsupported_format_error():
|
||||
logger.error("-" * 80)
|
||||
logger.error(" Input file does not appear to be a PE or ELF file.")
|
||||
|
||||
@@ -16,7 +16,7 @@ import collections
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
|
||||
from capa.helpers import weak_lru, assert_never
|
||||
from capa.helpers import assert_never
|
||||
|
||||
try:
|
||||
from functools import lru_cache
|
||||
@@ -115,10 +115,6 @@ class Scopes:
|
||||
static: Optional[str] = None
|
||||
dynamic: Optional[str] = None
|
||||
|
||||
@weak_lru()
|
||||
def __new__(cls, *args, **kwargs):
|
||||
return super().__new__(cls)
|
||||
|
||||
def __contains__(self, scope: Union[Scope, str]) -> bool:
|
||||
assert isinstance(scope, (Scope, str))
|
||||
return (scope == self.static) or (scope == self.dynamic)
|
||||
|
||||
Reference in New Issue
Block a user