[PATCH] Refactoring based on cppcheck suggestions
Richard Kimberly Heck
rikiheck at lyx.org
Fri Oct 2 20:42:22 UTC 2020
On 10/2/20 2:05 PM, Yuriy Skalko wrote:
> I've done some refactorings based on suggestions from cppcheck analyzer.
> diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
> index c3b59bb302..5f9e2d3093 100644
> --- a/src/lyxfind.cpp
> +++ b/src/lyxfind.cpp
> @@ -357,11 +357,10 @@ pair<bool, int> replaceOne(BufferView * bv,
> docstring searchstr,
> bool whole, bool forward, bool findnext)
> {
> Cursor & cur = bv->cursor();
> - bool found = false;
> if (!cur.selection()) {
> // no selection, non-empty search string: find it
> if (!searchstr.empty()) {
> - found = findOne(bv, searchstr, case_sens, whole, forward,
> true, findnext);
> + bool found = findOne(bv, searchstr, case_sens, whole,
> forward, true, findnext);
> return make_pair(found, 0);
> }
> // empty search string
> @@ -390,7 +389,7 @@ pair<bool, int> replaceOne(BufferView * bv,
> docstring searchstr,
> // no selection or current selection is not search word:
> // just find the search word
> if (!have_selection || !match) {
> - found = findOne(bv, searchstr, case_sens, whole, forward,
> true, findnext);
> + bool found = findOne(bv, searchstr, case_sens, whole,
> forward, true, findnext);
> return make_pair(found, 0);
> }
I guess found could be const both times, too.
Otherwise it looks fine to me.
Riki
More information about the lyx-devel
mailing list