]> git.lyx.org Git - features.git/commitdiff
Simplify code using range-based for loops
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 8 Jan 2018 14:15:29 +0000 (15:15 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 8 Jan 2018 14:16:58 +0000 (15:16 +0100)
src/BufferView.cpp

index fd709f37bfa491e88f1294119e2c785d118e87cb..3832982395d6a2d40dd252d2422de4efdea5edc8 100644 (file)
@@ -1901,14 +1901,9 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        Alert::warning(_("Branch already exists"), drtmp.message());
                        break;
                }
-               BranchList & branch_list = buffer_.params().branchlist();
-               vector<docstring> const branches =
-                       getVectorFromString(branch_name, branch_list.separator());
-               for (vector<docstring>::const_iterator it = branches.begin();
-                    it != branches.end(); ++it) {
-                       branch_name = *it;
-                       lyx::dispatch(FuncRequest(LFUN_BRANCH_INSERT, branch_name));
-               }
+               docstring const sep = buffer_.params().branchlist().separator();
+               for (docstring const & branch : getVectorFromString(branch_name, sep))
+                       lyx::dispatch(FuncRequest(LFUN_BRANCH_INSERT, branch));
                break;
        }
 
@@ -2395,18 +2390,11 @@ bool BufferView::setCursorFromInset(Inset const * inset)
 
 void BufferView::gotoLabel(docstring const & label)
 {
-       ListOfBuffers bufs = buffer().allRelatives();
-       ListOfBuffers::iterator it = bufs.begin();
-       for (; it != bufs.end(); ++it) {
-               Buffer const * buf = *it;
-
+       for (Buffer const * buf : buffer().allRelatives()) {
                // find label
-               shared_ptr<Toc> toc = buf->tocBackend().toc("label");
-               Toc::const_iterator toc_it = toc->begin();
-               Toc::const_iterator end = toc->end();
-               for (; toc_it != end; ++toc_it) {
-                       if (label == toc_it->str()) {
-                               lyx::dispatch(toc_it->action());
+               for (TocItem const & item : *buf->tocBackend().toc("label")) {
+                       if (label == item.str()) {
+                               lyx::dispatch(item.action());
                                return;
                        }
                }