D6404: Use static_cast when sure about the result

Kevin Funk noreply at phabricator.kde.org
Wed Jul 5 14:07:34 UTC 2017


kfunk added a comment.


  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.

INLINE COMMENTS

> kdevdocumentview.cpp:257
>      {
> -        if (KDevFileItem * fileItem = dynamic_cast<KDevDocumentItem*>(item)->fileItem())
> -        {
> +        if (KDevFileItem* fileItem = static_cast<KDevDocumentItem*>(item)->fileItem()) {
>              if (m_selectionModel->isSelected(m_proxy->mapFromSource(m_documentModel->indexFromItem(fileItem))))

Looks like we should rather `Q_ASSERT(fileItem)` here?

> grepoutputmodel.cpp:263
>      else
> -        current_item = dynamic_cast<GrepOutputItem*>(itemFromIndex(currentIdx));
> +        current_item = static_cast<GrepOutputItem*>(itemFromIndex(currentIdx));
>  

Note (unrelated): Should rename `current_item` to `currentItem`

REPOSITORY
  R33 KDevPlatform

REVISION DETAIL
  https://phabricator.kde.org/D6404

To: kossebau, #kdevelop
Cc: kfunk, kdevelop-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20170705/628496bf/attachment.html>


More information about the KDevelop-devel mailing list