From e1a810364a739de45f19701b3e95ea88f2b5ef5a Mon Sep 17 00:00:00 2001 From: Richard Kimberly Heck Date: Thu, 12 Nov 2020 18:49:03 -0500 Subject: [PATCH] Revert "Use the new optional template to simplify." I've done something wrong here, and I don't know what... This reverts commit 7b7b759bcbb389a1d176e4ccaedfaa3b51173c39. --- src/Buffer.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index b62228c415..c0a133fadd 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -97,7 +97,6 @@ #include "support/gzstream.h" #include "support/lstrings.h" #include "support/mutex.h" -#include "support/optional.h" #include "support/os.h" #include "support/Package.h" #include "support/PathChanger.h" @@ -216,11 +215,14 @@ public: typedef map MacroDefList; typedef map MacroMap; - optional getMacroDefinitions(docstring const & name) const + bool haveMacro(docstring const & name) const + { return macro_map_.count(name) != 0; } + + // Will assert if there is no such macro, so call haveMacro first! + MacroDefList const & getMacroDefinitions(docstring const & name) const { MacroMap::const_iterator it = macro_map_.find(name); - if (it == macro_map_.end()) - return {}; + LBUFERR(it != macro_map_.end()); return it->second; } @@ -3633,10 +3635,9 @@ MacroData const * Buffer::Impl::getBufferMacro(docstring const & name, MacroData const * bestData = nullptr; // find macro definitions for name - if (optional m = - macro_table.getMacroDefinitions(name)) - { - MacroTable::MacroDefList const & mdl = m.value(); + if (macro_table.haveMacro(name)) { + MacroTable::MacroDefList const & mdl = + macro_table.getMacroDefinitions(name); // find last definition in front of pos MacroTable::MacroDefList::const_iterator it = greatest_below(mdl, pos); -- 2.39.5