[PATCH] Refactoring based on cppcheck suggestions

Pavel Sanda sanda at lyx.org
Mon Oct 5 07:43:38 UTC 2020


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
> >>+++ b/src/LyXVC.cpp
> >>@@ -348,9 +348,7 @@ string LyXVC::toggleReadOnly()
> >>  bool LyXVC::inUse() const
> >>  {
> >>-	if (vcs)
> >>-		return true;
> >>-	return false;
> >>+	return static_cast<bool>(vcs);
> >>  }
> 
> I think I would prefer "vcs != nullptr", which is more explicit.
> 
> >I admit that while those above are correct and more succint I do not find it more readable.
> >But YMMV, am I the only one?
> 
> Personally, I find them more readable, because I do not have to follow the
> two branches to check what the code really does.

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


More information about the lyx-devel mailing list