Speedups: no cinit, no pickling (#2851)
* Speedups: remove unnecessary cinit This was meant for (memory) safety, but cython docs clearly state that this is done automatically. The code generated for cinit with args is what triggers a 'possible null deref' in clang's static analyzer, so by removing cinit, we can now use static analysis. * Speedups: disable pickling ... ... of LocationStore and internal classes. This reduces code size and avoids accidentally pickling them.
This commit is contained in:
parent
7fc159c881
commit
17c73916b7
|
@ -48,6 +48,7 @@ cdef struct IndexEntry:
|
||||||
size_t count
|
size_t count
|
||||||
|
|
||||||
|
|
||||||
|
@cython.auto_pickle(False)
|
||||||
cdef class LocationStore:
|
cdef class LocationStore:
|
||||||
"""Compact store for locations and their items in a MultiServer"""
|
"""Compact store for locations and their items in a MultiServer"""
|
||||||
# The original implementation uses Dict[int, Dict[int, Tuple(int, int, int]]
|
# The original implementation uses Dict[int, Dict[int, Tuple(int, int, int]]
|
||||||
|
@ -78,18 +79,6 @@ cdef class LocationStore:
|
||||||
size += sizeof(self._raw_proxies[0]) * self.sender_index_size
|
size += sizeof(self._raw_proxies[0]) * self.sender_index_size
|
||||||
return size
|
return size
|
||||||
|
|
||||||
def __cinit__(self, locations_dict: Dict[int, Dict[int, Sequence[int]]]) -> None:
|
|
||||||
self._mem = None
|
|
||||||
self._keys = None
|
|
||||||
self._items = None
|
|
||||||
self._proxies = None
|
|
||||||
self._len = 0
|
|
||||||
self.entries = NULL
|
|
||||||
self.entry_count = 0
|
|
||||||
self.sender_index = NULL
|
|
||||||
self.sender_index_size = 0
|
|
||||||
self._raw_proxies = NULL
|
|
||||||
|
|
||||||
def __init__(self, locations_dict: Dict[int, Dict[int, Sequence[int]]]) -> None:
|
def __init__(self, locations_dict: Dict[int, Dict[int, Sequence[int]]]) -> None:
|
||||||
self._mem = Pool()
|
self._mem = Pool()
|
||||||
cdef object key
|
cdef object key
|
||||||
|
@ -281,6 +270,7 @@ cdef class LocationStore:
|
||||||
entry.location not in checked])
|
entry.location not in checked])
|
||||||
|
|
||||||
|
|
||||||
|
@cython.auto_pickle(False)
|
||||||
@cython.internal # unsafe. disable direct import
|
@cython.internal # unsafe. disable direct import
|
||||||
cdef class PlayerLocationProxy:
|
cdef class PlayerLocationProxy:
|
||||||
cdef LocationStore _store
|
cdef LocationStore _store
|
||||||
|
|
Loading…
Reference in New Issue