From 6594e86f0a0efc9e3f2004507d913e3907d7d889 Mon Sep 17 00:00:00 2001 From: Sveinung Gundersen Date: Sun, 15 Sep 2024 06:42:49 +0200 Subject: [PATCH] Slight speedup of split_line --- src/omnipy/modules/raw/models.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/omnipy/modules/raw/models.py b/src/omnipy/modules/raw/models.py index 75c81a91..b8cafef4 100644 --- a/src/omnipy/modules/raw/models.py +++ b/src/omnipy/modules/raw/models.py @@ -87,11 +87,15 @@ class Params(ParamsBase): @classmethod def _split_line(cls, data: str) -> list[str]: - if cls.Params.strip: - data = data.strip(cls.Params.strip_chars) + strip = cls.Params.strip + strip_chars = cls.Params.strip_chars + delimiter = cls.Params.delimiter + + if strip: + data = data.strip(strip_chars) - items = data.split(cls.Params.delimiter) - return [item.strip(cls.Params.strip_chars) for item in items] if cls.Params.strip else items + items = data.split(delimiter) + return [item.strip(strip_chars) for item in items] if strip else items class _SplitToItemsModel(