# HG changeset patch # User Kosta A. ve7kcy@gmail.com # Date 1624429267 25200 # Tue Jun 22 23:21:07 2021 -0700 # Branch generic-csv # Node ID 6b816f380d29518e9d45fe6a6a8fa32d3e96b805 # Parent f586574bc8786fd6bef1e5d54d08d381c81edd47 Optimizing generic csv files load times by removing duplicate load for an empty list. Fixes #8991
diff --git a/chirp/chirp_common.py b/chirp/chirp_common.py --- a/chirp/chirp_common.py +++ b/chirp/chirp_common.py @@ -268,11 +268,11 @@ # or an empty list if none extra = []
- def __init__(self): + def __init__(self, number=0, empty=False, name=""): self.freq = 0 - self.number = 0 + self.number = number self.extd_number = "" - self.name = "" + self.name = name self.vfo = 0 self.rtone = 88.5 self.ctone = 88.5 @@ -290,7 +290,7 @@
self.comment = ""
- self.empty = False + self.empty = empty
self.immutable = []
diff --git a/chirp/drivers/generic_csv.py b/chirp/drivers/generic_csv.py --- a/chirp/drivers/generic_csv.py +++ b/chirp/drivers/generic_csv.py @@ -73,14 +73,12 @@ "Comment": (str, "comment"), }
- def _blank(self): + def _blank(self, setDefault=False): self.errors = [] - self.memories = [] - for i in range(0, 1000): - mem = chirp_common.Memory() - mem.number = i - mem.empty = True - self.memories.append(mem) + self.memories = [chirp_common.Memory(i, True) for i in range(0, 1000)] + if (setDefault): + self.memories[0].empty = False + self.memories[0].freq = 146010000
def __init__(self, pipe): chirp_common.FileBackedRadio.__init__(self, None) @@ -92,7 +90,7 @@ if self._filename and os.path.exists(self._filename): self.load() else: - self._blank() + self._blank(True)
def get_features(self): rf = chirp_common.RadioFeatures() diff --git a/chirp/ui/editorset.py b/chirp/ui/editorset.py --- a/chirp/ui/editorset.py +++ b/chirp/ui/editorset.py @@ -386,19 +386,6 @@ "export: {error}").format(error=e), self)
- def prime(self): - # NOTE: this is only called to prime new CSV files, so assume - # only one memory editor for now - mem = chirp_common.Memory() - mem.freq = 146010000 - - def cb(*args): - gobject.idle_add(self.editors["memedit0"].prefill) - - job = common.RadioJob(cb, "set_memory", mem) - job.set_desc(_("Priming memory")) - self.rthread.submit(job) - def tab_selected(self, notebook, foo, pagenum): widget = notebook.get_nth_page(pagenum) for k, v in self.editors.items(): diff --git a/chirp/ui/mainapp.py b/chirp/ui/mainapp.py --- a/chirp/ui/mainapp.py +++ b/chirp/ui/mainapp.py @@ -271,7 +271,6 @@ def do_new(self): eset = editorset.EditorSet(_("Untitled") + ".csv", self) self._connect_editorset(eset) - eset.prime() eset.show()
tab = self.tabs.append_page(eset, eset.get_tab_label()) diff --git a/chirp/ui/memedit.py b/chirp/ui/memedit.py --- a/chirp/ui/memedit.py +++ b/chirp/ui/memedit.py @@ -1062,10 +1062,7 @@ if not mem.empty or self.show_empty: gobject.idle_add(self.set_memory, mem) else: - mem = chirp_common.Memory() - mem.number = number - mem.name = "ERROR" - mem.empty = True + mem = chirp_common.Memory(number, True, "Error") gobject.idle_add(self.set_memory, mem)
for i in range(lo, hi+1):