The branch, cleanup/updateMacros3, has been updated.

- Log -----------------------------------------------------------------

commit 7b7b759bcbb389a1d176e4ccaedfaa3b51173c39
Author: Richard Kimberly Heck <rikih...@lyx.org>
Date:   Thu Nov 12 18:29:52 2020 -0500

    Use the new optional template to simplify.
    
    Thanks Yuriy!

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index c0a133f..b62228c 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -97,6 +97,7 @@
 #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"
@@ -215,14 +216,11 @@ public:
                typedef map<DocIterator, MacroDefinition> MacroDefList;
                typedef map<docstring, MacroDefList> MacroMap;
 
-               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
+               optional<MacroDefList> getMacroDefinitions(docstring const & 
name) const
                {
                        MacroMap::const_iterator it = macro_map_.find(name);
-                       LBUFERR(it != macro_map_.end());
+                       if (it == macro_map_.end())
+                               return {};
                        return it->second;
                }
 
@@ -3635,9 +3633,10 @@ MacroData const * Buffer::Impl::getBufferMacro(docstring 
const & name,
        MacroData const * bestData = nullptr;
 
        // find macro definitions for name
-       if (macro_table.haveMacro(name)) {
-               MacroTable::MacroDefList const & mdl = 
-                       macro_table.getMacroDefinitions(name);
+       if (optional<MacroTable::MacroDefList> m =
+                       macro_table.getMacroDefinitions(name))
+       {
+               MacroTable::MacroDefList const & mdl = m.value();
                // find last definition in front of pos
                MacroTable::MacroDefList::const_iterator it = 
                                greatest_below(mdl, pos);

-----------------------------------------------------------------------

Summary of changes:
 src/Buffer.cpp |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
Repository for new features
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to