Slight optimization to chat history pruning.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2710 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2003-07-14 23:46:03 +00:00
parent 96998e5678
commit 2726f6a29d
@@ -1,5 +1,5 @@
//
// $Id: SpeakProvider.java,v 1.13 2003/06/24 05:19:57 mdb Exp $
// $Id: SpeakProvider.java,v 1.14 2003/07/14 23:46:03 ray Exp $
package com.threerings.crowd.chat.server;
@@ -285,19 +285,14 @@ public class SpeakProvider
*/
protected static void pruneHistory (long now, HistoryList history)
{
int prunepos = -1;
for (int ii = 0, ll = history.size(); ii < ll; ii++) {
ChatMessage msg = (ChatMessage)history.get(ii);
if (now - msg.timestamp > HISTORY_EXPIRATION) {
// Log.info("Expiring from history " + msg + ".");
prunepos = ii;
} else {
int prunepos = 0;
for (int ll = history.size(); prunepos < ll; prunepos++) {
ChatMessage msg = (ChatMessage)history.get(prunepos);
if (now - msg.timestamp < HISTORY_EXPIRATION) {
break; // stop when we get to the first valid message
}
}
if (prunepos >= 0) {
history.remove(0, prunepos+1);
}
history.remove(0, prunepos);
}
/** Used to note the recipients of a chat message. */