[Libreoffice] [PUSHED] cppcheck cleanliness: duplicate expression
Eike Rathke
ooo at erack.de
Thu Sep 8 03:23:50 PDT 2011
Hi Stephan,
On Thursday, 2011-09-08 08:40:24 +0200, Stephan Bergmann wrote:
> On 09/08/2011 08:18 AM, Stephan Bergmann wrote:
> >Korrawit, Eike, did you check the context to verify that it should
> >really read
> >
> >a.nChar1 == a.nChar2
> >
> >instead of
> >
> >a.nChar1 == b.nChar1
> >
> >in the second term of
> >
> >>(a.nChar1 < b.nChar1) || ((a.nChar1 == a.nChar2) && (a.nChar2 <
> >>b.nChar2))
> >
> >? Somehow, that expression still looks suspicious. (At least, it does
> >not implement a lexicographical less-than relation. Not sure whether it
> >should or not, however.)
>
> Now actually looking at the context: Given that CmpKernData in
> vcl/source/gdi/outdev3.cxx is (only) used as an argument to
> std::sort, I'm pretty sure it must read (a.nChar1 == b.nChar1) to
> make that a true strict weak ordering, as required by std::sort.
> Pushed as <http://cgit.freedesktop.org/libreoffice/core/commit/?id=8b7978c822b11c53b4bd40bb0829e3ec205f1359>.
grml.. I looked at least thrice at that expression and came to the
conclusion that if for the second term two characters have identical
kerning in one pair, comparing the second character of both kernings
would be the weight. It didn't occur to me that the original expression
actually would had been wrong at two places.. but of course in a strict
weak ordering your expression makes perfectly sense.
Eike
--
PGP/OpenPGP/GnuPG encrypted mail preferred in all private communication.
Key ID: 0x293C05FD - 997A 4C60 CE41 0149 0DB3 9E96 2F1A D073 293C 05FD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20110908/135e0836/attachment.pgp>
More information about the LibreOffice
mailing list