Simplify code using range-based for loops

This commit is contained in:
Jean-Marc Lasgouttes 2018-01-08 15:15:29 +01:00
parent 6093a3a9b1
commit 1de6d3f3f0

View 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;
}
}