Review Request 128954: [KTp/Declarative/MessagesModel] Implemented message sort by sent timestamp

Alexandr Akulich akulichalexander at gmail.com
Tue Sep 20 10:39:37 UTC 2016



> On Sept. 20, 2016, 3:06 p.m., Aleix Pol Gonzalez wrote:
> > KTp/Declarative/messages-model.cpp, line 222
> > <https://git.reviewboard.kde.org/r/128954/diff/1/?file=477161#file477161line222>
> >
> >     Use iterators?
> 
> Alexandr Akulich wrote:
>     How to get an index from iterator?
> 
> Aleix Pol Gonzalez wrote:
>     You can count in parallel without calling `QList::operator[]` on the index.

Actually I call ```const T &at(int i) const;```. And what is the reason to use iterators, if you still suggest to use a counter? Do you actually think that
```
    int i = d->messages.count() - 1;
    for (auto it = d->messages.constEnd(); it != d->messages.constBegin(); --it, --i) {
        if (sentTimestamp > it->message.time()) {
            newMessageIndex = i;
            break;
        }
        // Or do you suggest to place --i; here?
    }
```
is more readable, than plain
```
    for (int i = d->messages.count() - 1; i >= 0; --i) {
        if (sentTimestamp > d->messages.at(i).message.time()) {
            newMessageIndex = i;
            break;
        }
    }
```
?

IMO it is a common practice to use iterators if you don't need index (and just use the index otherwise). It is a bit more optimal and I don't made an error in the condition.


- Alexandr


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/128954/#review99301
-----------------------------------------------------------


On Sept. 20, 2016, 2:51 p.m., Alexandr Akulich wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/128954/
> -----------------------------------------------------------
> 
> (Updated Sept. 20, 2016, 2:51 p.m.)
> 
> 
> Review request for Telepathy.
> 
> 
> Repository: ktp-common-internals
> 
> 
> Description
> -------
> 
> Implemented message sort by sent timestamp (if available).
> 
> This fixes order of scrollback messages.
> 
> 
> Diffs
> -----
> 
>   KTp/Declarative/messages-model.cpp dc1088c 
> 
> Diff: https://git.reviewboard.kde.org/r/128954/diff/
> 
> 
> Testing
> -------
> 
> Works, fixes the issue.
> 
> 
> Thanks,
> 
> Alexandr Akulich
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-telepathy/attachments/20160920/104b1c37/attachment.html>


More information about the KDE-Telepathy mailing list