Some type safety, redundant cast removal, and other code hygiene.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4879 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -97,8 +97,7 @@ public class OccupantDirector extends BasicDirector
|
||||
public OccupantInfo getOccupantInfo (int bodyOid)
|
||||
{
|
||||
// make sure we're somewhere
|
||||
return (_place == null) ? null :
|
||||
(OccupantInfo)_place.occupantInfo.get(Integer.valueOf(bodyOid));
|
||||
return (_place == null) ? null : _place.occupantInfo.get(Integer.valueOf(bodyOid));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -416,7 +416,7 @@ public class Streamer
|
||||
/**
|
||||
* Constructs a streamer for the specified target class.
|
||||
*/
|
||||
protected Streamer (Class target)
|
||||
protected Streamer (Class<?> target)
|
||||
throws IOException
|
||||
{
|
||||
// keep a handle on the class
|
||||
|
||||
@@ -147,7 +147,7 @@ public class InvocationDirector
|
||||
|
||||
// if we're logged on, clear out any receiver id mapping
|
||||
if (_clobj != null) {
|
||||
Registration rreg = (Registration)_clobj.receivers.get(receiverCode);
|
||||
Registration rreg = _clobj.receivers.get(receiverCode);
|
||||
if (rreg == null) {
|
||||
Log.warning("Receiver unregistered for which we have no id to code mapping " +
|
||||
"[code=" + receiverCode + "].");
|
||||
|
||||
@@ -34,31 +34,28 @@ import com.threerings.presents.dobj.InvocationNotificationEvent;
|
||||
public abstract class InvocationSender
|
||||
{
|
||||
/**
|
||||
* Requests that the specified invocation notification be packaged up
|
||||
* and sent to the supplied target client.
|
||||
* Requests that the specified invocation notification be packaged up and sent to the supplied
|
||||
* target client.
|
||||
*/
|
||||
public static void sendNotification (
|
||||
ClientObject target, String receiverCode, int methodId, Object[] args)
|
||||
{
|
||||
// convert the receiver hash id into the code used on this
|
||||
// specific client
|
||||
Registration rreg = (Registration)target.receivers.get(receiverCode);
|
||||
Registration rreg = target.receivers.get(receiverCode);
|
||||
if (rreg == null) {
|
||||
Log.warning("Unable to locate receiver for invocation " +
|
||||
"service notification [clobj=" + target.who() +
|
||||
", code=" + receiverCode + ", methId=" + methodId +
|
||||
", args=" + StringUtil.toString(args) + "].");
|
||||
Log.warning("Unable to locate receiver for invocation service notification " +
|
||||
"[clobj=" + target.who() + ", code=" + receiverCode +
|
||||
", methId=" + methodId + ", args=" + StringUtil.toString(args) + "].");
|
||||
Thread.dumpStack();
|
||||
|
||||
} else {
|
||||
// Log.info("Sending notification [target=" + target +
|
||||
// ", code=" + receiverCode + ", methodId=" + methodId +
|
||||
// ", args=" + StringUtil.toString(args) + "].");
|
||||
// Log.info("Sending notification [target=" + target + ", code=" + receiverCode +
|
||||
// ", methodId=" + methodId + ", args=" + StringUtil.toString(args) + "].");
|
||||
|
||||
// create and dispatch an invocation notification event
|
||||
target.postEvent(
|
||||
new InvocationNotificationEvent(
|
||||
target.getOid(), rreg.receiverId, methodId, args));
|
||||
new InvocationNotificationEvent(target.getOid(), rreg.receiverId, methodId, args));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import sun.misc.Perf;
|
||||
|
||||
import com.samskivert.util.AuditLogger;
|
||||
import com.samskivert.util.HashIntMap;
|
||||
import com.samskivert.util.Histogram;
|
||||
@@ -297,8 +295,7 @@ public class PresentsDObjectMgr
|
||||
*/
|
||||
protected void processUnit (Object unit)
|
||||
{
|
||||
long start = _timer.highResCounter();
|
||||
long freq = _timer.highResFrequency();
|
||||
long start = System.nanoTime();
|
||||
|
||||
// keep track of the largest queue size we've seen
|
||||
int queueSize = _evqueue.size();
|
||||
@@ -339,8 +336,7 @@ public class PresentsDObjectMgr
|
||||
}
|
||||
|
||||
// compute the elapsed time in microseconds
|
||||
long elapsed = _timer.highResCounter() - start;
|
||||
elapsed = elapsed * 1000000 / freq;
|
||||
long elapsed = (System.nanoTime() - start)/1000;
|
||||
|
||||
// report excessively long units
|
||||
if (elapsed > 500000 && !(unit instanceof LongRunnable)) {
|
||||
@@ -859,17 +855,16 @@ public class PresentsDObjectMgr
|
||||
protected static void registerEventHelpers ()
|
||||
{
|
||||
Class[] ptypes = new Class[] { DEvent.class, DObject.class };
|
||||
Class omgrcl = PresentsDObjectMgr.class;
|
||||
Method method;
|
||||
|
||||
try {
|
||||
method = omgrcl.getMethod("objectDestroyed", ptypes);
|
||||
method = PresentsDObjectMgr.class.getMethod("objectDestroyed", ptypes);
|
||||
_helpers.put(ObjectDestroyedEvent.class, method);
|
||||
|
||||
method = omgrcl.getMethod("objectAdded", ptypes);
|
||||
method = PresentsDObjectMgr.class.getMethod("objectAdded", ptypes);
|
||||
_helpers.put(ObjectAddedEvent.class, method);
|
||||
|
||||
method = omgrcl.getMethod("objectRemoved", ptypes);
|
||||
method = PresentsDObjectMgr.class.getMethod("objectRemoved", ptypes);
|
||||
_helpers.put(ObjectRemovedEvent.class, method);
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -981,9 +976,6 @@ public class PresentsDObjectMgr
|
||||
* thread. */
|
||||
protected Thread _dobjThread;
|
||||
|
||||
/** Used during unit profiling for timing values. */
|
||||
protected Perf _timer = Perf.getPerf();
|
||||
|
||||
/** A monotonically increasing counter used to assign an id to all dispatched events. */
|
||||
protected long _nextEventId = 1;
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public class PresentsInvoker extends Invoker
|
||||
|
||||
if (PresentsDObjectMgr.UNIT_PROF_ENABLED) {
|
||||
for (Object key : _tracker.keySet()) {
|
||||
UnitProfile profile = (UnitProfile)_tracker.get(key);
|
||||
UnitProfile profile = _tracker.get(key);
|
||||
if (key instanceof Class) {
|
||||
key = StringUtil.shortClassName((Class)key);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ClassUtil
|
||||
{
|
||||
Class tclass = target.getClass();
|
||||
String key = tclass.getName() + ":" + name;
|
||||
Method method = (Method)cache.get(key);
|
||||
Method method = cache.get(key);
|
||||
|
||||
if (method == null) {
|
||||
method = findMethod(tclass, name);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class StreamableHashMap<K,V> extends HashMap<K,V>
|
||||
int ecount = size();
|
||||
out.writeInt(ecount);
|
||||
for (Iterator<Map.Entry<K,V>> iter = entrySet().iterator(); iter.hasNext(); ) {
|
||||
Map.Entry<K,V> entry = (Map.Entry<K,V>) iter.next();
|
||||
Map.Entry<K,V> entry = iter.next();
|
||||
out.writeObject(entry.getKey());
|
||||
out.writeObject(entry.getValue());
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class TrackedObject
|
||||
{
|
||||
Class clazz = getClass();
|
||||
synchronized (_map) {
|
||||
int[] count = (int[])_map.get(clazz);
|
||||
int[] count = _map.get(clazz);
|
||||
if (count == null) {
|
||||
_map.put(clazz, count = new int[1]);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class TrackedObject
|
||||
{
|
||||
Class clazz = getClass();
|
||||
synchronized (_map) {
|
||||
int[] count = (int[])_map.get(clazz);
|
||||
int[] count = _map.get(clazz);
|
||||
if (count != null) {
|
||||
count[0]--;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user