aboutsummaryrefslogtreecommitdiff
path: root/room.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2016-04-11 12:43:32 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2016-04-11 12:45:00 +0900
commitdef5a08b4d360f6035ad4c420f0206ad6f96e0bd (patch)
tree65eea09fa684406cd6cc2a47bcba69e74b8cb3e8 /room.cpp
parent8045e36b6b8597120f46e0d4d42cf87ac790351b (diff)
downloadlibquotient-def5a08b4d360f6035ad4c420f0206ad6f96e0bd.tar.gz
libquotient-def5a08b4d360f6035ad4c420f0206ad6f96e0bd.zip
Factor out the code that searches an insertion point in a timeline.
This is used once in the library and, I guess, twice more in the Quaternion. Implemented as a template function that is equally suitable for Event and Message, and any container that supports STL-style iterators (QList and other Qt containers do).
Diffstat (limited to 'room.cpp')
-rw-r--r--room.cpp10
1 files changed, 1 insertions, 9 deletions
diff --git a/room.cpp b/room.cpp
index 99d7f810..c5b674ae 100644
--- a/room.cpp
+++ b/room.cpp
@@ -284,15 +284,7 @@ Connection* Room::connection()
void Room::processMessageEvent(Event* event)
{
- for( int i=0; i<d->messageEvents.count(); i++ )
- {
- if( event->timestamp() < d->messageEvents.at(i)->timestamp() )
- {
- d->messageEvents.insert(i, event);
- return;
- }
- }
- d->messageEvents.append(event);
+ d->messageEvents.insert(findInsertionPos(d->messageEvents, event), event);
}
void Room::processStateEvent(Event* event)