Added some warnings for illegal DSet operations and added a small

optimization in the process.
Previously, we dumped stack on the server if a entry add was illegal but
did nothing for update/remove.
On the client, we complained for updates and (indirectly) adds, but not
removes.
Now we complain everywhere.
And- as an added bonus, on the server we now do only one binary search for
updates and removals. Whee!


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3528 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2005-04-29 02:30:23 +00:00
parent f5e5d273e7
commit 16322b1422
5 changed files with 39 additions and 26 deletions
@@ -1,5 +1,5 @@
//
// $Id: EntryRemovedEvent.java,v 1.17 2004/08/27 02:20:20 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -21,6 +21,8 @@
package com.threerings.presents.dobj;
import com.threerings.presents.Log;
/**
* An entry removed event is dispatched when an entry is removed from a
* {@link DSet} attribute of a distributed object. It can also be
@@ -82,10 +84,14 @@ public class EntryRemovedEvent extends NamedEvent
{
if (_oldEntry == UNSET_OLD_ENTRY) {
DSet set = (DSet)target.getAttribute(_name);
// fetch the previous value for interested callers
_oldEntry = set.get(_key);
// remove it from the set
set.removeKey(_key);
// remove, fetch the previous value for interested callers
_oldEntry = set.removeKey(_key);
if (_oldEntry == null) {
// complain if there was actually nothing there
Log.warning("No matching entry to remove [key=" + _key +
", set=" + set + "].");
return false;
}
}
return true;
}