From f0658ca167995c818bd1f59d182109f986cafa26 Mon Sep 17 00:00:00 2001 From: ZhymabekRoman Date: Thu, 2 Jan 2025 19:58:08 +0500 Subject: [PATCH] refactor(utf_handler): add __slots__ for memory optimization and remove unused position_mappings property --- .../src/freedium_library/utils/utils/utf_handler.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/freedium-library/src/freedium_library/utils/utils/utf_handler.py b/freedium-library/src/freedium_library/utils/utils/utf_handler.py index f143f28..5dabe17 100644 --- a/freedium-library/src/freedium_library/utils/utils/utf_handler.py +++ b/freedium-library/src/freedium_library/utils/utils/utf_handler.py @@ -124,6 +124,8 @@ class PositionTracker: class UTFHandler(ABC): + __slots__ = ("_string", "_encoding", "_position_tracker") + def __init__(self, string: str, encoding: UTFEncoding): logger.debug( f"Initializing UTFHandler with string: '{string}' and encoding: {encoding}" @@ -212,10 +214,6 @@ class UTFHandler(ABC): logger.debug(f"Final original position: {original_pos}") return original_pos - @property - def position_mappings(self) -> List[CharacterMapping]: - return self._position_tracker.get() - def insert(self, encoded_position: int, string_to_insert: str) -> None: logger.info( f"Inserting '{string_to_insert}' at encoded position {encoded_position}"