lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make Pitch::to_string() more robust (issue 581580043 by address@hidd


From: hanwenn
Subject: Re: Make Pitch::to_string() more robust (issue 581580043 by address@hidden)
Date: Sat, 01 Feb 2020 13:09:18 -0800

https://codereview.appspot.com/581580043/diff/557260048/lily/pitch.cc
File lily/pitch.cc (right):

https://codereview.appspot.com/581580043/diff/557260048/lily/pitch.cc#newcode162
lily/pitch.cc:162: if (qt >= 0 && qt < int (sizeof(accname) /
sizeof(const char*))) {
On 2020/02/01 11:19:12, Dan Eble wrote:
> Space after sizeof?

clang-format ftw!

done.

https://codereview.appspot.com/581580043/diff/557260048/lily/pitch.cc#newcode162
lily/pitch.cc:162: if (qt >= 0 && qt < int (sizeof(accname) /
sizeof(const char*))) {
On 2020/02/01 11:19:12, Dan Eble wrote:
> Instead of casting to int and checking that the value is non-negative,
why not 
> 
>   size_t qt = ...
>   if (qt < ...)
> 
> A pre-C++11 way to improve computing the array size is not to repeat
the element
> type:
> 
>   sizeof (accname) / sizeof (accname[0])
> 

thanks, done.

> A C++11 way to simplify the code that uses the size is to use
std::array, though
> it would come at the cost of declaring the count.

Decline; then I might as well just write 

  if (qt < 9) ..

https://codereview.appspot.com/581580043/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]