Add == and != operators to KIO::UDSEntry
AcceptedPublic

Authored by meven on Mon, Sep 2, 10:03 AM.

Details

Reviewers
ngraham
dfaure
Group Reviewers
Frameworks
Summary

I felt it was missing.

Test Plan

ctest

Diff Detail

Repository
R241 KIO
Branch
arcpatch-D23667
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 16551
Build 16569: arc lint + arc unit
meven created this revision.Mon, Sep 2, 10:03 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptMon, Sep 2, 10:03 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
meven requested review of this revision.Mon, Sep 2, 10:03 AM
ngraham added a subscriber: ngraham.Tue, Sep 3, 1:01 AM

I know it seems silly for such tiny functions, but can you follow the pattern and keep only the function definitions in the header file and move the actual logic into the .cpp file?

src/core/udsentry.h
130

as other -> as the other

131

Just 5.62 (Frameworks don't have minor versions)

139

ditto

140

ditto

pino added a subscriber: pino.Tue, Sep 3, 4:38 AM

Please move the implementations in the cpp file, otherwise it will be impossible to change/fix the implementation later on in a binary compatible way.

Also:

  • both the operators ought to be const, since they do not mutate the object (and otherwise they cannot be used to compare const objects)
  • please fix the style in the declarations: const UDSEntry& other -> const UDSEntry &other
pino added a comment.Tue, Sep 3, 4:39 AM

Oh, and also please add tests for them in UDSEntryTest.

meven updated this revision to Diff 65295.Tue, Sep 3, 9:11 AM

Move impl to cpp file, fix comment, add unit test

meven updated this revision to Diff 65296.Tue, Sep 3, 9:13 AM

Clean spaces changes

meven updated this revision to Diff 65297.Tue, Sep 3, 9:19 AM

Fix test udsentrybenchmark

meven edited the test plan for this revision. (Show Details)Tue, Sep 3, 9:19 AM
meven edited the test plan for this revision. (Show Details)
meven updated this revision to Diff 65298.Tue, Sep 3, 9:22 AM

fix since mention

ngraham accepted this revision.Tue, Sep 3, 12:43 PM
This revision is now accepted and ready to land.Tue, Sep 3, 12:43 PM
pino added a comment.Tue, Sep 3, 10:02 PM

please use QCOMPARE/QVERIFY instead of Q_ASSERT in QTest tests

autotests/udsentrytest.cpp
301

typo, "additional"

meven updated this revision to Diff 65607.Sat, Sep 7, 9:29 PM

Fix test and implementation

meven updated this revision to Diff 65608.Sat, Sep 7, 9:30 PM
meven marked 5 inline comments as done.

typo fix

meven updated this revision to Diff 65705.Mon, Sep 9, 9:19 PM

Remove unneeded friend function declarations

meven updated this revision to Diff 66086.Sat, Sep 14, 7:56 PM

Update @since references

meven added a comment.Sat, Sep 14, 7:56 PM

@pino if this is fine for you...

dfaure accepted this revision.Fri, Sep 20, 12:37 PM
dfaure added a subscriber: dfaure.

Looks ok, but I'm just curious about the use case. "I felt it was missing" doesn't sound as strong an argument as "I need this"...

Slaves are supposed to mostly create those, not compare them, and apps are supposed to use KFileItem rather than UDSEntry directly.

meven added a comment.Fri, Sep 20, 6:52 PM

Looks ok, but I'm just curious about the use case. "I felt it was missing" doesn't sound as strong an argument as "I need this"...

Slaves are supposed to mostly create those, not compare them, and apps are supposed to use KFileItem rather than UDSEntry directly.

The use case I felt I might need it, is when running stats for a file which I already stated earlier and have a KFileItem already.
And checking if the file changed between the two stats.
Without this it would be hard to do.

Using the entry to compare the KFileItem seemed to me the simplest course of action (KFileItem equals compares only file path) but lacked the equal operators.

Note that there is KFileItem::cmp for a more thorough comparison of two fileitems. But it only looks at some UDS fields -- those that matter at the KDirLister level.
Or maybe it shows that UDSEntry::operator== was missing so KFileItem::cmp uses a poor man's version of that ;)
This confirms the need for such an operator== indeed (though I wouldn't change the implementation of KFileItem::cmp until we see a need to do that).

Thanks for the explanation.