From defce2375199b9a48137b8a23e0ccf39f7e70853 Mon Sep 17 00:00:00 2001 From: mdb Date: Tue, 19 Feb 2002 03:39:41 +0000 Subject: [PATCH] Use a SortableArrayList instead of sorting a regular array list to avoid creating craploads of objects every time an interval expires. git-svn-id: https://samskivert.googlecode.com/svn/trunk@584 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/util/IntervalManager.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/IntervalManager.java b/projects/samskivert/src/java/com/samskivert/util/IntervalManager.java index 5bf725b2..2a0f99bd 100644 --- a/projects/samskivert/src/java/com/samskivert/util/IntervalManager.java +++ b/projects/samskivert/src/java/com/samskivert/util/IntervalManager.java @@ -1,5 +1,5 @@ // -// $Id: IntervalManager.java,v 1.4 2001/09/15 17:22:11 mdb Exp $ +// $Id: IntervalManager.java,v 1.5 2002/02/19 03:39:41 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -20,8 +20,6 @@ package com.samskivert.util; -import java.util.*; -import java.util.Collections; import com.samskivert.Log; /** @@ -93,7 +91,7 @@ public class IntervalManager extends Thread IntervalItem item = new IntervalItem(i, delay, arg, recur); _hash.put(item.id, item); _schedule.add(item); - Collections.sort(_schedule); + _schedule.sort(); if (item.endtime < _nextwake) { _mgr.notify(); } @@ -191,7 +189,7 @@ public class IntervalManager extends Thread // since we're definitionally not sleeping, we can just // insert into the queue without checking wait times.. _schedule.add(item); - Collections.sort(_schedule); + _schedule.sort(); } else { // otherwise, get rid of this interval altogether @@ -245,7 +243,8 @@ public class IntervalManager extends Thread // If we someday find that we have a lot of intervaleds, we may want // to rewrite this such that we can add and remove intervaleds much // faster. - protected static ArrayList _schedule = new ArrayList(); + protected static SortableArrayList _schedule = new SortableArrayList(); + protected static HashIntMap _hash = new HashIntMap(); protected static long _nextwake = Long.MAX_VALUE;