[LyX/master] Simplify code by using initializer lists for vectors.

Jean-Marc Lasgouttes lasgouttes at lyx.org
Sat May 23 14:51:33 UTC 2020


commit 8d51b3e7bb439e815bb96fa7959aa332227fab6a
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Sat May 23 17:10:17 2020 +0200

    Simplify code by using initializer lists for vectors.
    
    { REFERENCE_NEXT, NOTE_NEXT } can be used as a value for a
    vector<FuncCode> since C++11.
---
 src/BufferView.cpp |   25 ++++---------------------
 1 files changed, 4 insertions(+), 21 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 43d74b6..2eaa434 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -179,13 +179,6 @@ bool findInset(DocIterator & dit, vector<InsetCode> const & codes,
 }
 
 
-/// Looks for next inset with the given code
-void findInset(DocIterator & dit, InsetCode code, bool same_content)
-{
-	findInset(dit, vector<InsetCode>(1, code), same_content);
-}
-
-
 /// Moves cursor to the next inset with one of the given codes.
 void gotoInset(BufferView * bv, vector<InsetCode> const & codes,
 	       bool same_content)
@@ -202,13 +195,6 @@ void gotoInset(BufferView * bv, vector<InsetCode> const & codes,
 }
 
 
-/// Moves cursor to the next inset with given code.
-void gotoInset(BufferView * bv, InsetCode code, bool same_content)
-{
-	gotoInset(bv, vector<InsetCode>(1, code), same_content);
-}
-
-
 /// A map from a Text to the associated text metrics
 typedef map<Text const *, TextMetrics> TextMetricsCache;
 
@@ -1530,7 +1516,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 	}
 
 	case LFUN_NOTE_NEXT:
-		gotoInset(this, NOTE_CODE, false);
+		gotoInset(this, { NOTE_CODE }, false);
 		// FIXME: if SinglePar is changed to act on the inner
 		// paragraph, this will not be OK anymore. The update is
 		// useful for auto-open collapsible insets.
@@ -1538,10 +1524,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 		break;
 
 	case LFUN_REFERENCE_NEXT: {
-		vector<InsetCode> tmp;
-		tmp.push_back(LABEL_CODE);
-		tmp.push_back(REF_CODE);
-		gotoInset(this, tmp, true);
+		gotoInset(this, { LABEL_CODE, REF_CODE }, true);
 		// FIXME: if SinglePar is changed to act on the inner
 		// paragraph, this will not be OK anymore. The update is
 		// useful for auto-open collapsible insets.
@@ -1723,7 +1706,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 
 	case LFUN_BIBTEX_DATABASE_ADD: {
 		Cursor tmpcur = cur;
-		findInset(tmpcur, BIBTEX_CODE, false);
+		findInset(tmpcur, { BIBTEX_CODE }, false);
 		InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur,
 						BIBTEX_CODE);
 		if (inset) {
@@ -1735,7 +1718,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 
 	case LFUN_BIBTEX_DATABASE_DEL: {
 		Cursor tmpcur = cur;
-		findInset(tmpcur, BIBTEX_CODE, false);
+		findInset(tmpcur, { BIBTEX_CODE }, false);
 		InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur,
 						BIBTEX_CODE);
 		if (inset) {


More information about the lyx-cvs mailing list