[PATCH] Refactoring based on cppcheck suggestions

Richard Kimberly Heck rikiheck at lyx.org
Mon Oct 5 15:32:04 UTC 2020


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
>>> @@ -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.

Yes.


>> 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.

Me too.

Riki




More information about the lyx-devel mailing list