From 305e6764b1bd5eb0e3a1e612bb85e5401f402a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=CC=81clav=20Slavi=CC=81k?= Date: Mon, 6 May 2024 18:28:19 +0200 Subject: [PATCH] Revert CatalogItem::GetTranslation() optimization Partially reverts 1ed2ac37. Don't specialize GetTranslation() (i.e. n=0) to return a reference. It doesn't have measurable effect after the other optimizations and it causes crashes in code that implicitly assumes that GetTranslation() is safe to call e.g. on non-translation files too (see e.g. 6b893be6). It's just not worth the risk. --- src/catalog.cpp | 2 +- src/catalog.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/catalog.cpp b/src/catalog.cpp index 4d49902396..1d0695a80f 100644 --- a/src/catalog.cpp +++ b/src/catalog.cpp @@ -867,7 +867,7 @@ void CatalogItem::SetFuzzy(bool fuzzy) wxString CatalogItem::GetTranslation(unsigned idx) const { if (idx >= GetNumberOfTranslations()) - return wxEmptyString; + return wxString(); else return m_translations[idx]; } diff --git a/src/catalog.h b/src/catalog.h index a47c2ddbd9..940df918cb 100644 --- a/src/catalog.h +++ b/src/catalog.h @@ -144,8 +144,7 @@ class CatalogItem unsigned GetPluralFormsCount() const; /// Returns the nth-translation. - wxString GetTranslation(unsigned n) const; - const wxString& GetTranslation() const { return m_translations[0]; } + wxString GetTranslation(unsigned n = 0) const; /// Returns all translations. const wxArrayString& GetTranslations() const { return m_translations; }