[LyX/master] Simplify code a bit. Should be equivalent, unless backs is empty!

2020-07-08 Thread Richard Kimberly Heck
commit 3c094c739ba38f43edf9698ac37dd9eee62080b1
Author: Richard Kimberly Heck 
Date:   Wed Jul 8 23:59:15 2020 -0400

Simplify code a bit. Should be equivalent, unless backs is empty!
---
 src/BufferParams.cpp |   10 --
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 4ed8b4e..4a70ed8 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -2653,12 +2653,10 @@ FormatList const & BufferParams::exportableFormats(bool 
only_viewable) const
  excludes.insert("xetex");
}
 
-   FormatList result =
-   theConverters().getReachable(backs[0], only_viewable, true, 
excludes);
-   vector::const_iterator it = backs.begin() + 1;
-   for (; it != backs.end(); ++it) {
-   FormatList r = theConverters().getReachable(*it, only_viewable,
-   
false, excludes);
+   FormatList result;
+   for (auto const & b : backs) {
+   FormatList r =
+   theConverters().getReachable(b, only_viewable, false, 
excludes);
result.insert(result.end(), r.begin(), r.end());
}
sort(result.begin(), result.end(), Format::formatSorter);
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Simplify code a bit.

2018-03-02 Thread Richard Heck
commit 5531b40c9be1f0c8dd4c13ad30925ffe31a3dacf
Author: Richard Heck 
Date:   Fri Mar 2 23:12:11 2018 -0500

Simplify code a bit.

(cherry picked from commit 490506c45f200093229e7d7289aa1b3195783cf1)
---
 lib/configure.py |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/configure.py b/lib/configure.py
index 49abf77..df07e46 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -1771,14 +1771,14 @@ def checkTeXAllowSpaces():
 def rescanTeXFiles():
 ''' Run kpsewhich to update information about TeX files '''
 logger.info("+Indexing TeX files... ")
-if not os.path.isfile( os.path.join(srcdir, 'scripts', 'TeXFiles.py') ):
+tfscript = os.path.join(srcdir, 'scripts', 'TeXFiles.py')
+if not os.path.isfile(tfscript):
 logger.error("configure: error: cannot find TeXFiles.py script")
 sys.exit(1)
 interpreter = sys.executable
 if interpreter == '':
 interpreter = "python"
-tfp = cmdOutput('"%s" -tt "%s"' % (interpreter,\
-  os.path.join(srcdir, 'scripts', 'TeXFiles.py')))
+tfp = cmdOutput('"%s" -tt "%s"' % (interpreter, tfscript))
 logger.info(tfp)
 logger.info("\tdone")
 


[LyX master] Simplify code a bit: If we only accept CITE_CODE, there is no need to pass it.

2013-04-25 Thread Richard Heck
The branch, master, has been updated.

- Log -

commit 6c983d6cd16ad09f7610d13a9e53c721f930e02a
Author: Richard Heck rgh...@lyx.org
Date:   Sat Apr 6 12:34:26 2013 -0400

Simplify code a bit: If we only accept CITE_CODE, there is no need
to pass it.

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 7f3773c..5333642 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -3359,12 +3359,9 @@ void Buffer::clearReferenceCache() const
 }
 
 
-void Buffer::changeRefsIfUnique(docstring const  from, docstring const  to,
-   InsetCode code)
+void Buffer::changeRefsIfUnique(docstring const  from, docstring const  to)
 {
//FIXME: This does not work for child documents yet.
-   LASSERT(code == CITE_CODE, /**/);
-
reloadBibInfoCache();
 
// Check if the label 'from' appears more than once
@@ -3382,14 +3379,12 @@ void Buffer::changeRefsIfUnique(docstring const  from, 
docstring const  to,
 
string const paramName = key;
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
-   if (it-lyxCode() == code) {
-   InsetCommand * inset = it-asInsetCommand();
-   if (!inset)
-   continue;
-   docstring const oldValue = inset-getParam(paramName);
-   if (oldValue == from)
-   inset-setParam(paramName, to);
-   }
+   if (it-lyxCode() != CITE_CODE) 
+   continue;
+   InsetCommand * inset = it-asInsetCommand();
+   docstring const oldValue = inset-getParam(paramName);
+   if (oldValue == from)
+   inset-setParam(paramName, to);
}
 }
 
diff --git a/src/Buffer.h b/src/Buffer.h
index a1afc8b..4e55654 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -591,8 +591,7 @@ public:
 
/// Replace the inset contents for insets which InsetCode is equal
/// to the passed \p inset_code.
-   void changeRefsIfUnique(docstring const  from, docstring const  to,
-   InsetCode code);
+   void changeRefsIfUnique(docstring const  from, docstring const  to);
 
/// get source code (latex/docbook) for some paragraphs, or all 
paragraphs
/// including preamble
diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp
index d8a0666..5241859 100644
--- a/src/insets/InsetBibitem.cpp
+++ b/src/insets/InsetBibitem.cpp
@@ -177,8 +177,7 @@ void InsetBibitem::doDispatch(Cursor  cur, FuncRequest  
cmd)
setParam(label, p[label]);
if (p[key] != old_key) {
updateCommand(p[key]);
-   cur.bv().buffer().changeRefsIfUnique(old_key,
-   params()[key], CITE_CODE);
+   cur.bv().buffer().changeRefsIfUnique(old_key, 
params()[key]);
cur.forceBufferUpdate();
buffer().invalidateBibinfoCache();
}

---

Summary of changes:
 src/Buffer.cpp  |   19 +++
 src/Buffer.h|3 +--
 src/insets/InsetBibitem.cpp |3 +--
 3 files changed, 9 insertions(+), 16 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository


[LyX master] Simplify code a bit: If we only accept CITE_CODE, there is no need to pass it.

2013-04-25 Thread Richard Heck
The branch, master, has been updated.

- Log -

commit 6c983d6cd16ad09f7610d13a9e53c721f930e02a
Author: Richard Heck 
Date:   Sat Apr 6 12:34:26 2013 -0400

Simplify code a bit: If we only accept CITE_CODE, there is no need
to pass it.

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 7f3773c..5333642 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -3359,12 +3359,9 @@ void Buffer::clearReferenceCache() const
 }
 
 
-void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to,
-   InsetCode code)
+void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to)
 {
//FIXME: This does not work for child documents yet.
-   LASSERT(code == CITE_CODE, /**/);
-
reloadBibInfoCache();
 
// Check if the label 'from' appears more than once
@@ -3382,14 +3379,12 @@ void Buffer::changeRefsIfUnique(docstring const & from, 
docstring const & to,
 
string const paramName = "key";
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
-   if (it->lyxCode() == code) {
-   InsetCommand * inset = it->asInsetCommand();
-   if (!inset)
-   continue;
-   docstring const oldValue = inset->getParam(paramName);
-   if (oldValue == from)
-   inset->setParam(paramName, to);
-   }
+   if (it->lyxCode() != CITE_CODE) 
+   continue;
+   InsetCommand * inset = it->asInsetCommand();
+   docstring const oldValue = inset->getParam(paramName);
+   if (oldValue == from)
+   inset->setParam(paramName, to);
}
 }
 
diff --git a/src/Buffer.h b/src/Buffer.h
index a1afc8b..4e55654 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -591,8 +591,7 @@ public:
 
/// Replace the inset contents for insets which InsetCode is equal
/// to the passed \p inset_code.
-   void changeRefsIfUnique(docstring const & from, docstring const & to,
-   InsetCode code);
+   void changeRefsIfUnique(docstring const & from, docstring const & to);
 
/// get source code (latex/docbook) for some paragraphs, or all 
paragraphs
/// including preamble
diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp
index d8a0666..5241859 100644
--- a/src/insets/InsetBibitem.cpp
+++ b/src/insets/InsetBibitem.cpp
@@ -177,8 +177,7 @@ void InsetBibitem::doDispatch(Cursor & cur, FuncRequest & 
cmd)
setParam("label", p["label"]);
if (p["key"] != old_key) {
updateCommand(p["key"]);
-   cur.bv().buffer().changeRefsIfUnique(old_key,
-   params()["key"], CITE_CODE);
+   cur.bv().buffer().changeRefsIfUnique(old_key, 
params()["key"]);
cur.forceBufferUpdate();
buffer().invalidateBibinfoCache();
}

---

Summary of changes:
 src/Buffer.cpp  |   19 +++
 src/Buffer.h|3 +--
 src/insets/InsetBibitem.cpp |3 +--
 3 files changed, 9 insertions(+), 16 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository