mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Do not run updateMacros if the buffer has not changed
Each buffer now has an id which is increased when it is marked dirty (or when one of its relatives is marked dirty). This can be a big win since updateMacros is very expensive.
This commit is contained in:
parent
6e81f31722
commit
999fb37ebb
@ -254,6 +254,11 @@ public:
|
|||||||
///
|
///
|
||||||
Undo undo_;
|
Undo undo_;
|
||||||
|
|
||||||
|
/// This is increased every time the buffer or one of its relatives is marked dirty
|
||||||
|
int id_ = 0;
|
||||||
|
/// The buffer id at last updateMacros invokation
|
||||||
|
int update_macros_id_ = -1;
|
||||||
|
|
||||||
/// A cache for the bibfiles (including bibfiles of loaded child
|
/// A cache for the bibfiles (including bibfiles of loaded child
|
||||||
/// documents), needed for appropriate update of natbib labels.
|
/// documents), needed for appropriate update of natbib labels.
|
||||||
mutable docstring_list bibfiles_cache_;
|
mutable docstring_list bibfiles_cache_;
|
||||||
@ -790,6 +795,20 @@ Undo const & Buffer::undo() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Buffer::id() const
|
||||||
|
{
|
||||||
|
return d->id_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Buffer::updateId()
|
||||||
|
{
|
||||||
|
++d->id_;
|
||||||
|
for(Buffer * b : allRelatives())
|
||||||
|
++(b->d->id_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Buffer::setChild(DocIterator const & dit, Buffer * child)
|
void Buffer::setChild(DocIterator const & dit, Buffer * child)
|
||||||
{
|
{
|
||||||
d->children_positions[child] = dit;
|
d->children_positions[child] = dit;
|
||||||
@ -3305,6 +3324,9 @@ void Buffer::markDirty()
|
|||||||
|
|
||||||
for (auto & depit : d->dep_clean)
|
for (auto & depit : d->dep_clean)
|
||||||
depit.second = false;
|
depit.second = false;
|
||||||
|
|
||||||
|
// Update the buffer and its relatives' ids.
|
||||||
|
updateId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3899,6 +3921,11 @@ void Buffer::updateMacros() const
|
|||||||
if (d->macro_lock)
|
if (d->macro_lock)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// early exit if the buffer has not changed since last time
|
||||||
|
if (d->update_macros_id_ == d->id_)
|
||||||
|
return;
|
||||||
|
d->update_macros_id_ = d->id_;
|
||||||
|
|
||||||
LYXERR(Debug::MACROS, "updateMacro of " << d->filename.onlyFileName());
|
LYXERR(Debug::MACROS, "updateMacro of " << d->filename.onlyFileName());
|
||||||
|
|
||||||
// start with empty table
|
// start with empty table
|
||||||
|
@ -661,6 +661,12 @@ public:
|
|||||||
///
|
///
|
||||||
Undo const & undo() const;
|
Undo const & undo() const;
|
||||||
|
|
||||||
|
/// poor man versioning of the buffer (and its relatives).
|
||||||
|
int id() const;
|
||||||
|
/// change the id of this buffer and its relatives (indicating
|
||||||
|
/// something has changed). This is currently used by updateMacros().
|
||||||
|
void updateId();
|
||||||
|
|
||||||
/// This function is called when the buffer is changed.
|
/// This function is called when the buffer is changed.
|
||||||
void changed(bool update_metrics) const;
|
void changed(bool update_metrics) const;
|
||||||
///
|
///
|
||||||
|
@ -529,9 +529,11 @@ void Undo::Private::doUndoRedoAction(CursorData & cur, UndoElementStack & stack,
|
|||||||
|
|
||||||
if (!undo.cur_before.empty())
|
if (!undo.cur_before.empty())
|
||||||
cur = undo.cur_before;
|
cur = undo.cur_before;
|
||||||
if (undo.lyx_clean)
|
if (undo.lyx_clean) {
|
||||||
buffer_.markClean();
|
buffer_.markClean();
|
||||||
else
|
// since we have changed the buffer, update its id.
|
||||||
|
buffer_.updateId();
|
||||||
|
} else
|
||||||
buffer_.markDirty();
|
buffer_.markDirty();
|
||||||
// Now that we're done with undo, we pop it off the stack.
|
// Now that we're done with undo, we pop it off the stack.
|
||||||
stack.pop();
|
stack.pop();
|
||||||
|
Loading…
Reference in New Issue
Block a user