[clazy] [Bug 410714] clazy-detaching-temporary: Don't warn on detaching pointer values

2019-08-25 Thread Sergio Martins
https://bugs.kde.org/show_bug.cgi?id=410714

Sergio Martins  changed:

   What|Removed |Added

 Resolution|--- |NOT A BUG
 Status|REPORTED|RESOLVED

-- 
You are receiving this mail because:
You are watching all bug changes.

[clazy] [Bug 410714] clazy-detaching-temporary: Don't warn on detaching pointer values

2019-08-08 Thread Sergio Martins
https://bugs.kde.org/show_bug.cgi?id=410714

--- Comment #3 from Sergio Martins  ---
It's indeed safe, but the warning is not about safety, it's about an unneeded
QList copy when detaching a temporary.

The performance impact can vary from negligeable if the list is small and
detach called just a few times to high if the list is big and detached often.


Clazy can't know the size of the list nor does it know how often some method is
called (could even be called in a loop from another translation unit).


By using constFirst() instead of first() then we're certain that there's no
detach and there's no guessing needed in the first place.

-- 
You are receiving this mail because:
You are watching all bug changes.

[clazy] [Bug 410714] clazy-detaching-temporary: Don't warn on detaching pointer values

2019-08-08 Thread Markus
https://bugs.kde.org/show_bug.cgi?id=410714

--- Comment #2 from Markus  ---
(In reply to Sergio Martins from comment #1)
> That QList is not a pointer
> 
> It's doing axes(Qt::Horizontal).first(), not axes(Qt::Horizontal)->first()

This is of course correct, sorry for being unclear in my description. 

I was referring to the contents of the QList - the QList contains pointers to
the axes, and it is safe and intended to manipulate these via the returned
temporary QList directly.

I reported this because it just didn't make sense to me to see a warning in
this case, for the following reasons: 
* The warning is specific to the call to QList::first(), which is likely to get
called on small lists. Here it's a case where typically only one item is
returned.
* If the list contents are pointers, it's not so expensive to have a detaching
copy, nor is it so problematic since the pointers in the list are still
pointing to valid objects.
* The warning is about a "detaching-temporary". This first made me think that
"axes(..).first()" points to a temporary and not the real pointee. But this is
not the case.
* It seems to be the suggested way to use the API of QChart ...

-- 
You are receiving this mail because:
You are watching all bug changes.

[clazy] [Bug 410714] clazy-detaching-temporary: Don't warn on detaching pointer values

2019-08-08 Thread Sergio Martins
https://bugs.kde.org/show_bug.cgi?id=410714

--- Comment #1 from Sergio Martins  ---
That QList is not a pointer

It's doing axes(Qt::Horizontal).first(), not axes(Qt::Horizontal)->first()

-- 
You are receiving this mail because:
You are watching all bug changes.