#375831 - Sort empty file extensions correctly

Authored by palant on Feb 13 2017, 8:24 PM.

Description

#375831 - Sort empty file extensions correctly

Summary:
This change makes sure that empty strings are sorted before non-empty strings. Note that it is treating the case where both strings are equal specially, this is for consistency with the logic at the bottom of compareTextsAlphabetical() and compareTextsCharacterCode(). I don't see a difference if I leave out this case but if it is important then personally I would have written this differently:

if (aS2.length() == 0) {
    return false;
} else if (aS1.length() == 0) {
    return true;
}

The checks in compareTextsAlphabetical() can be simplified similarly:

if (lPositionS2 == aS2.length()) return false;
else if (lPositionS1 == aS1.length()) return true;

These two comparisons produce the same result as the six comparisons currently there.

Test Plan: See STR in bug.

Reviewers: Krusader, martinkostolny, abika, asensi

Reviewed By: Krusader, martinkostolny, abika, asensi

Subscribers: asensi, martinkostolny, Krusader

Tags: Krusader

Differential Revision: https://phabricator.kde.org/D4417

BUG: 375831

Details

Committed
Alexander Bikadorov <alex.bikadorov@kdemail.net>Feb 13 2017, 8:34 PM
Reviewer
Krusader
Parents
R167:5766bb472efb: Panel: show terminal entry in KrPopupMenu's "Open with" submenu only if oneā€¦
Branches
Unknown
Tags
Unknown
Alexander Bikadorov <alex.bikadorov@kdemail.net> committed R167:1db4a2b8a3e6: #375831 - Sort empty file extensions correctly (authored by palant).Feb 13 2017, 8:34 PM