Compare commits

...

7 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
8e181e992d Avoid a couple of copies.
Spotted by Coverity scan.
2024-09-12 18:33:45 +02:00
Jean-Marc Lasgouttes
7a99ef7fbb Make docstring parameters const references
Spotted by Coverity scan.
2024-09-12 18:28:26 +02:00
Jean-Marc Lasgouttes
b743870d71 Graph::getReachable(): pass a parameter by const reference
Spotted by coverity.
2024-09-12 18:20:43 +02:00
Jean-Marc Lasgouttes
b1bbf64a28 Avoid a copy
Spotted by Coverity scan.
2024-09-12 18:05:50 +02:00
Jean-Marc Lasgouttes
cc40330e00 Avoid a couple of copies
Spotted by Coverity scan.
2024-09-12 17:59:41 +02:00
Jean-Marc Lasgouttes
91f3f27545 GuiWorkArea: pass KeySymbol parameters as const references
Spotted by Coverity scan.
2024-09-12 17:52:57 +02:00
Jean-Marc Lasgouttes
8ea9c2da03 Avoid a couple copies in Trans::addDeadKeys().
Spotted by Coverity scan.
2024-09-12 17:24:32 +02:00
10 changed files with 24 additions and 33 deletions

View File

@ -590,9 +590,8 @@ Buffer * Buffer::cloneWithChildren() const
{ {
BufferMap bufmap; BufferMap bufmap;
cloned_buffers.emplace_back(new CloneList); cloned_buffers.emplace_back(new CloneList);
CloneList_ptr clones = cloned_buffers.back();
cloneWithChildren(bufmap, clones); cloneWithChildren(bufmap, cloned_buffers.back());
// make sure we got cloned // make sure we got cloned
BufferMap::const_iterator bit = bufmap.find(this); BufferMap::const_iterator bit = bufmap.find(this);

View File

@ -79,9 +79,8 @@ Graph::EdgePath const
} }
Graph::EdgePath const Graph::EdgePath const Graph::getReachable(int from, bool only_viewable, bool clear_visited,
Graph::getReachable(int from, bool only_viewable, set<int> const & excludes)
bool clear_visited, set<int> excludes)
{ {
EdgePath result; EdgePath result;
queue<int> Q; queue<int> Q;

View File

@ -33,8 +33,8 @@ public:
/// \return a vector of the vertices from which "to" can be reached /// \return a vector of the vertices from which "to" can be reached
EdgePath const getReachableTo(int to, bool clear_visited); EdgePath const getReachableTo(int to, bool clear_visited);
/// \return a vector of the reachable vertices, avoiding all "excludes" /// \return a vector of the reachable vertices, avoiding all "excludes"
EdgePath const getReachable(int from, bool only_viewable, EdgePath const getReachable(int from, bool only_viewable, bool clear_visited,
bool clear_visited, std::set<int> excludes = std::set<int>()); std::set<int> const & excludes = std::set<int>());
/// can "from" be reached from "to"? /// can "from" be reached from "to"?
bool isReachable(int from, int to); bool isReachable(int from, int to);
/// find a path from "from" to "to". always returns one of the /// find a path from "from" to "to". always returns one of the

View File

@ -176,19 +176,13 @@ tex_accent getkeymod(string const &);
void Trans::addDeadkey(tex_accent accent, docstring const & keys) void Trans::addDeadkey(tex_accent accent, docstring const & keys)
{ {
KmodInfo tmp; kmod_list_[accent] = KmodInfo(keys, accent, KmodException());
tmp.data = keys;
tmp.accent = accent;
kmod_list_[accent] = tmp;
for (char_type key : keys) { for (char_type key : keys) {
// FIXME This is a hack. // FIXME This is a hack.
// tmp is no valid UCS4 string, but misused to store the // tmp is no valid UCS4 string, but misused to store the
// accent. // accent.
docstring tmpd; keymap_[key] = docstring() + char_type(0) + char_type(accent);
tmpd += char_type(0);
tmpd += char_type(accent);
keymap_[key] = tmpd;
} }
} }

View File

@ -112,6 +112,9 @@ public:
/// ///
KmodInfo() : accent(TEX_NOACCENT) {} KmodInfo() : accent(TEX_NOACCENT) {}
/// ///
KmodInfo(docstring const & d, tex_accent a, KmodException const & e)
: data(d), accent(a), exception_list(e) {}
///
docstring data; docstring data;
/// ///
tex_accent accent; tex_accent accent;

View File

@ -1037,7 +1037,7 @@ bool CompressorProxy::emitCheck(bool isAutoRepeat)
} }
void CompressorProxy::slot(KeySymbol sym, KeyModifier mod, bool isAutoRepeat) void CompressorProxy::slot(KeySymbol const & sym, KeyModifier mod, bool isAutoRepeat)
{ {
if (emitCheck(isAutoRepeat)) if (emitCheck(isAutoRepeat))
Q_EMIT signal(sym, mod); Q_EMIT signal(sym, mod);

View File

@ -102,7 +102,7 @@ Q_SIGNALS:
/// ///
void bufferViewChanged(); void bufferViewChanged();
/// send key event to CompressorProxy /// send key event to CompressorProxy
void compressKeySym(KeySymbol sym, KeyModifier mod, bool isAutoRepeat); void compressKeySym(KeySymbol const & sym, KeyModifier mod, bool isAutoRepeat);
private Q_SLOTS: private Q_SLOTS:
/// Scroll the BufferView. /// Scroll the BufferView.
@ -170,9 +170,9 @@ class CompressorProxy : public QObject
bool emitCheck(bool isAutoRepeat); bool emitCheck(bool isAutoRepeat);
bool flag_; bool flag_;
// input: event to compress // input: event to compress
Q_SLOT void slot(KeySymbol sym, KeyModifier mod, bool isAutoRepeat); Q_SLOT void slot(KeySymbol const & sym, KeyModifier mod, bool isAutoRepeat);
// output: compressed event // output: compressed event
Q_SIGNAL void signal(KeySymbol sym, KeyModifier mod); Q_SIGNAL void signal(KeySymbol const & sym, KeyModifier mod);
public: public:
// No default constructor, since the proxy must be a child of the // No default constructor, since the proxy must be a child of the
// target object. // target object.

View File

@ -1725,10 +1725,6 @@ void MenuDefinition::expandCiteStyles(BufferView const * bv)
&& (keys.size() > 1 && (keys.size() > 1
|| !citinset->getParam("pretextlist").empty() || !citinset->getParam("pretextlist").empty()
|| !citinset->getParam("posttextlist").empty()); || !citinset->getParam("posttextlist").empty());
vector<pair<docstring, docstring>> pres =
citinset->getQualifiedLists(citinset->getParam("pretextlist"));
vector<pair<docstring, docstring>> posts =
citinset->getQualifiedLists(citinset->getParam("posttextlist"));
CiteItem ci; CiteItem ci;
ci.textBefore = citinset->getParam("before"); ci.textBefore = citinset->getParam("before");
@ -1738,8 +1734,10 @@ void MenuDefinition::expandCiteStyles(BufferView const * bv)
ci.context = CiteItem::Dialog; ci.context = CiteItem::Dialog;
ci.max_size = 40; ci.max_size = 40;
ci.isQualified = qualified; ci.isQualified = qualified;
ci.pretexts = pres; ci.pretexts =
ci.posttexts = posts; citinset->getQualifiedLists(citinset->getParam("pretextlist"));
ci.posttexts =
citinset->getQualifiedLists(citinset->getParam("posttextlist"));
BiblioInfo::CiteStringMap citeStrings = BiblioInfo::CiteStringMap citeStrings =
buf->masterBibInfo().getCiteStrings(keys, citeStyleList, bv->buffer(), ci); buf->masterBibInfo().getCiteStrings(keys, citeStyleList, bv->buffer(), ci);

View File

@ -502,8 +502,6 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const
&& (keys.size() > 1 && (keys.size() > 1
|| !getParam("pretextlist").empty() || !getParam("pretextlist").empty()
|| !getParam("posttextlist").empty()); || !getParam("posttextlist").empty());
QualifiedList pres = getQualifiedLists(getParam("pretextlist"));
QualifiedList posts = getQualifiedLists(getParam("posttextlist"));
CiteItem ci; CiteItem ci;
ci.textBefore = getParam("before"); ci.textBefore = getParam("before");
@ -512,8 +510,8 @@ docstring InsetCitation::complexLabel(bool for_xhtml) const
ci.Starred = starred; ci.Starred = starred;
ci.max_size = UINT_MAX; ci.max_size = UINT_MAX;
ci.isQualified = qualified; ci.isQualified = qualified;
ci.pretexts = pres; ci.pretexts = getQualifiedLists(getParam("pretextlist"));
ci.posttexts = posts; ci.posttexts = getQualifiedLists(getParam("posttextlist"));
if (for_xhtml) { if (for_xhtml) {
ci.max_key_size = UINT_MAX; ci.max_key_size = UINT_MAX;
ci.context = CiteItem::Export; ci.context = CiteItem::Export;

View File

@ -32,11 +32,11 @@ public:
/// ///
docstring const & formattedCounter() const { return formatted_counter_; } docstring const & formattedCounter() const { return formatted_counter_; }
/// ///
void setCounterValue(docstring cv) { counter_value_ = cv; } void setCounterValue(docstring const & cv) { counter_value_ = cv; }
/// ///
void setPrettyCounter(docstring pc) { pretty_counter_ = pc; } void setPrettyCounter(docstring const & pc) { pretty_counter_ = pc; }
/// ///
void setFormattedCounter(docstring fc) { formatted_counter_ = fc; } void setFormattedCounter(docstring const & fc) { formatted_counter_ = fc; }
/// ///
int rowFlags() const override { return CanBreakBefore | CanBreakAfter; } int rowFlags() const override { return CanBreakBefore | CanBreakAfter; }
/// Updates only the label string, doesn't handle undo nor references. /// Updates only the label string, doesn't handle undo nor references.