Use pattern matching instead of if and else that return true and false
Differential Revision: https://phabricator.kde.org/D16576