From a2625c4726c8f5551321095a16659ad3a6a086b2 Mon Sep 17 00:00:00 2001 From: Filip Sykala Date: Wed, 13 Oct 2021 09:01:56 +0200 Subject: [PATCH] change assert to conditions --- src/libslic3r/TextConfigurationSerialization.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/TextConfigurationSerialization.hpp b/src/libslic3r/TextConfigurationSerialization.hpp index cd1121a6f0..b1ed25ba19 100644 --- a/src/libslic3r/TextConfigurationSerialization.hpp +++ b/src/libslic3r/TextConfigurationSerialization.hpp @@ -79,10 +79,15 @@ private: if (pos == data.npos) return data; std::string copy = data; // copy do { - assert(copy[pos] == letter); - assert(copy[pos + 1] == letter); + std::string::size_type pos_plus_one = pos + 1; + // is data endig with odd number of letters + if (pos_plus_one == copy.npos) return copy; + // is pair count of letter - should not appear after twice + if (copy[pos_plus_one] != letter) continue; + + // reduce by removing first copy.erase(pos, size_t(1)); - pos = copy.find(letter, pos + 1); + pos = copy.find(letter, pos_plus_one); } while (pos != copy.npos); return copy; };