[PATCH] Refactoring based on cppcheck suggestions

Jean-Marc Lasgouttes lasgouttes at lyx.org
Mon Oct 5 07:33:48 UTC 2020


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.

JMarc



More information about the lyx-devel mailing list