From: Richard Heck Date: Wed, 29 Sep 2010 11:59:31 +0000 (+0000) Subject: Use getChildren() to collect all the relatives. Note that this makes X-Git-Tag: 2.0.0~2480 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=f5696b8872695f4d6af8e028905f36a46b489fab;p=lyx.git Use getChildren() to collect all the relatives. Note that this makes allRelatives() "stable", in the sense that what it returns does not depend upon which Buffer we start with. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35530 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index e7c49cc2b1..7123264281 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -143,9 +143,6 @@ void showPrintError(string const & name) } // namespace anon -typedef std::set BufferSet; - - class Buffer::Impl { public: @@ -169,8 +166,6 @@ public: void updateMacros(DocIterator & it, DocIterator & scope); /// void setLabel(ParIterator & it, UpdateType utype) const; - /// - void collectRelatives(BufferSet & bufs) const; /** If we have branches that use the file suffix feature, return the file name with suffix appended. @@ -2485,29 +2480,11 @@ Buffer const * Buffer::parent() const } -void Buffer::Impl::collectRelatives(BufferSet & bufs) const -{ - bufs.insert(owner_); - if (parent()) - parent()->d->collectRelatives(bufs); - - // loop over children - BufferPositionMap::const_iterator it = children_positions.begin(); - BufferPositionMap::const_iterator end = children_positions.end(); - for (; it != end; ++it) - bufs.insert(const_cast(it->first)); -} - - ListOfBuffers Buffer::allRelatives() const { - BufferSet bufs; - d->collectRelatives(bufs); - BufferSet::iterator it = bufs.begin(); - ListOfBuffers ret; - for (; it != bufs.end(); ++it) - ret.push_back(*it); - return ret; + if (parent()) + return parent()->allRelatives(); + return getChildren(/* true */); } @@ -2545,11 +2522,9 @@ void Buffer::getChildren(ListOfBuffers & clist, bool grand_children) const for (; it != end; ++it) { Buffer * child = const_cast(it->first); clist.push_back(child); - if (grand_children) { + if (grand_children) // there might be grandchildren - ListOfBuffers glist = child->getChildren(); - clist.insert(clist.end(), glist.begin(), glist.end()); - } + child->getChildren(clist /*, true */); } }