Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-07 Thread Yuriy Skalko
> What José said. > > Riki Yes, backward compatibility wins again, even the *man* cannot change that. Yuriy -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Richard Kimberly Heck
On 10/5/20 11:06 AM, Scott Kostyshak wrote: > On Mon, Oct 05, 2020 at 12:54:18PM +0200, Pavel Sanda wrote: >> On Mon, Oct 05, 2020 at 01:48:20PM +0300, Yuriy Skalko wrote: Ok, probably question of habit. When I see former three lines like above I immediately know what's going on. Wi

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Richard Kimberly Heck
On 10/5/20 3:33 AM, Jean-Marc Lasgouttes wrote: > Le 05/10/2020 à 09:20, Pavel Sanda a écrit : >> On Sun, Oct 04, 2020 at 07:27:28PM +0300, Yuriy Skalko wrote: >>> diff --git a/src/LyXVC.cpp b/src/LyXVC.cpp >>> index 806d5e8143..9af9372cbe 100644 >>> --- a/src/LyXVC.cpp >>> +++ b/src/LyXVC.cpp >>>

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Richard Kimberly Heck
On 10/5/20 7:03 AM, Yuriy Skalko wrote: >> What happens if size_t numberofcells is 0 and cell is also 0? What is 0 >> - 1 for an unsigned int? Maybe numberofcells can't be 0, but still it >> seems a bit confusing. I'd suggest: >> >> return cell + 1 >= numberofcells; >> >> instead. >> >> Riki >

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Scott Kostyshak
On Mon, Oct 05, 2020 at 05:13:09PM +0200, Jean-Marc Lasgouttes wrote: > Le 05/10/2020 à 17:06, Scott Kostyshak a écrit : > > After thinking about it more though, I agree that the new version seems > > to be better in terms of having only one return, although it's > > interesting that some minor com

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Jean-Marc Lasgouttes
Le 05/10/2020 à 17:06, Scott Kostyshak a écrit : After thinking about it more though, I agree that the new version seems to be better in terms of having only one return, although it's interesting that some minor complexity (e.g., the cast or the explicit comparison to nullptr) has to be added to

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Scott Kostyshak
On Mon, Oct 05, 2020 at 12:54:18PM +0200, Pavel Sanda wrote: > On Mon, Oct 05, 2020 at 01:48:20PM +0300, Yuriy Skalko wrote: > > > Ok, probably question of habit. When I see former three lines like above > > > I > > > immediately > > > know what's going on. With new changes and I need to stop and

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Jean-Marc Lasgouttes
Le 05/10/2020 à 16:27, José Abílio Matos a écrit : On Monday, October 5, 2020 1:52:19 PM WEST Jean-Marc Lasgouttes wrote: C++ stl uses unsigned for vector indices. JMarc What the *man* has to say about that (pag. 123 from the article below): So we fork the standard library? JMarc -- lyx-d

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread José Abílio Matos
On Monday, October 5, 2020 1:52:19 PM WEST Jean-Marc Lasgouttes wrote: > C++ stl uses unsigned for vector indices. > > JMarc What the *man* has to say about that (pag. 123 from the article below): " The most contentious part of getting span into C++20 turned out to be the type of subscripts and

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Jean-Marc Lasgouttes
I committed the updated patch. JMarc -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Jean-Marc Lasgouttes
Le 05/10/2020 à 13:03, Yuriy Skalko a écrit : I assume that if numberofcells is 0 there cannot be 0-th cell, but it still worth to change the code. Another question is why to bother with unsigned's usage at all? In my experience unsigned types are only useful for flag values when definitely will

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Yuriy Skalko
> What happens if size_t numberofcells is 0 and cell is also 0? What is 0 > - 1 for an unsigned int? Maybe numberofcells can't be 0, but still it > seems a bit confusing. I'd suggest: > > return cell + 1 >= numberofcells; > > instead. > > Riki I assume that if numberofcells is 0 there canno

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Pavel Sanda
On Mon, Oct 05, 2020 at 01:48:20PM +0300, Yuriy Skalko wrote: > > Ok, probably question of habit. When I see former three lines like above I > > immediately > > know what's going on. With new changes and I need to stop and start > > thinking > > what it does... > > > > Pavel > > Just look at t

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Yuriy Skalko
> Ok, probably question of habit. When I see former three lines like above I > immediately > know what's going on. With new changes and I need to stop and start thinking > what it does... > > Pavel Just look at the return expression as the answer to the question in function name: > bool Buffe

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Pavel Sanda
On Mon, Oct 05, 2020 at 09:33:48AM +0200, Jean-Marc Lasgouttes wrote: > Le 05/10/2020 ?? 09:20, Pavel Sanda a écrit : > >On Sun, Oct 04, 2020 at 07:27:28PM +0300, Yuriy Skalko wrote: > >>diff --git a/src/LyXVC.cpp b/src/LyXVC.cpp > >>index 806d5e8143..9af9372cbe 100644 > >>--- a/src/LyXVC.cpp > >>+

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Jean-Marc Lasgouttes
Le 05/10/2020 à 09:20, Pavel Sanda a écrit : On Sun, Oct 04, 2020 at 07:27:28PM +0300, Yuriy Skalko wrote: diff --git a/src/LyXVC.cpp b/src/LyXVC.cpp index 806d5e8143..9af9372cbe 100644 --- a/src/LyXVC.cpp +++ b/src/LyXVC.cpp @@ -348,9 +348,7 @@ string LyXVC::toggleReadOnly() bool LyXVC::in

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-05 Thread Pavel Sanda
On Sun, Oct 04, 2020 at 07:27:28PM +0300, Yuriy Skalko wrote: > @@ -4010,10 +4009,7 @@ InsetLabel const * Buffer::insetLabel(docstring const > & label, > > bool Buffer::activeLabel(docstring const & label) const > { > - if (!insetLabel(label, true)) > - return false; > - > -

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-04 Thread Richard Kimberly Heck
On 10/4/20 12:27 PM, Yuriy Skalko wrote: >> Thanks, it is in. >> >> JMarc > Continuing with refactoring LyX code. This all looks fine, except for this one: diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 8458ce4728..fdfef40556 100644 --- a/src/insets/InsetTabular.cpp

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-04 Thread Yuriy Skalko
> Thanks, it is in. > > JMarc Continuing with refactoring LyX code. Yuriy From 1a6c4ef50c2c182996bf546baf5f632a6e1d347e Mon Sep 17 00:00:00 2001 From: Yuriy Skalko Date: Sun, 4 Oct 2020 19:22:43 +0300 Subject: [PATCH] Refactoring --- src/Buffer.cpp| 6 +- src/Buff

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-03 Thread Jean-Marc Lasgouttes
Le 02/10/2020 à 20:05, Yuriy Skalko a écrit : I've done some refactorings based on suggestions from cppcheck analyzer. Thanks, it is in. JMarc -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-02 Thread Pavel Sanda
On Fri, Oct 02, 2020 at 09:05:13PM +0300, Yuriy Skalko wrote: > I've done some refactorings based on suggestions from cppcheck analyzer. Looks good. Pavel -- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel

Re: [PATCH] Refactoring based on cppcheck suggestions

2020-10-02 Thread Richard Kimberly Heck
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 replaceOne(BufferVie

[PATCH] Refactoring based on cppcheck suggestions

2020-10-02 Thread Yuriy Skalko
I've done some refactorings based on suggestions from cppcheck analyzer. Yuriy From ac663a3837b7ef425c852aedf2731ec5aa3079c2 Mon Sep 17 00:00:00 2001 From: Yuriy Skalko Date: Thu, 1 Oct 2020 13:34:15 +0300 Subject: [PATCH] Refactoring based on cppcheck suggestions --- src/Autho