Use static_cast when sure about the result
ClosedPublic

Authored by kossebau on Jun 27 2017, 11:36 AM.

Diff Detail

Repository
R33 KDevPlatform
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kossebau created this revision.Jun 27 2017, 11:36 AM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptJun 27 2017, 11:36 AM
kfunk added a subscriber: kfunk.Jul 5 2017, 2:07 PM

Micro-optimization at best, but looks okay.

Also: I usually transform Foo* foo = static_cast<Foo*>(...) into auto foo = static_cast<Foo*>(...) -- easier to read; there's already the type information on the RHS.

plugins/documentview/kdevdocumentview.cpp
257 ↗(On Diff #15910)

Looks like we should rather Q_ASSERT(fileItem) here?

plugins/grepview/grepoutputmodel.cpp
263 ↗(On Diff #15910)

Note (unrelated): Should rename current_item to currentItem

kfunk accepted this revision.Jul 5 2017, 2:07 PM
This revision is now accepted and ready to land.Jul 5 2017, 2:07 PM
kossebau marked an inline comment as done.Jul 5 2017, 5:46 PM
kossebau added inline comments.
plugins/documentview/kdevdocumentview.cpp
257 ↗(On Diff #15910)

Rather no, fileItem is allowed to be nullptr. If something could be tested, dynamic_cast<KDevDocumentItem*> would be it, though there is no real danger some none-KDevDocumentItem is coming from the model,
But actually that whole code rather should be redone, as fileitem() does some kind of dynamic casting as well, as only KDevFileItem implements it. Possibly code from before RTII was a okay thing. Left for someone else/some other idle time.

This revision was automatically updated to reflect the committed changes.
kossebau marked an inline comment as done.
kfunk added inline comments.Jul 5 2017, 5:48 PM
plugins/documentview/kdevdocumentview.cpp
257 ↗(On Diff #15910)

Ah, sorry, I missed the ->fileItem(). Makes sense then.