Only rewrite out the tileset map if it has changed.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1180 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: MapFileTileSetIDBroker.java,v 1.3 2002/04/03 22:03:23 mdb Exp $
|
// $Id: MapFileTileSetIDBroker.java,v 1.4 2002/04/03 22:42:22 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media.tile.tools;
|
package com.threerings.media.tile.tools;
|
||||||
|
|
||||||
@@ -38,6 +38,7 @@ public class MapFileTileSetIDBroker implements TileSetIDBroker
|
|||||||
FileInputStream fin = new FileInputStream(mapfile);
|
FileInputStream fin = new FileInputStream(mapfile);
|
||||||
ObjectInputStream oin = new ObjectInputStream(fin);
|
ObjectInputStream oin = new ObjectInputStream(fin);
|
||||||
_nextTileSetID = oin.readInt();
|
_nextTileSetID = oin.readInt();
|
||||||
|
_storedTileSetID = _nextTileSetID;
|
||||||
_map = (HashMap)oin.readObject();
|
_map = (HashMap)oin.readObject();
|
||||||
oin.close();
|
oin.close();
|
||||||
|
|
||||||
@@ -75,6 +76,11 @@ public class MapFileTileSetIDBroker implements TileSetIDBroker
|
|||||||
public void commit ()
|
public void commit ()
|
||||||
throws PersistenceException
|
throws PersistenceException
|
||||||
{
|
{
|
||||||
|
// only write ourselves out if we've changed
|
||||||
|
if (_storedTileSetID == _nextTileSetID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileOutputStream fout = new FileOutputStream(_mapfile);
|
FileOutputStream fout = new FileOutputStream(_mapfile);
|
||||||
ObjectOutputStream oout = new ObjectOutputStream(fout);
|
ObjectOutputStream oout = new ObjectOutputStream(fout);
|
||||||
@@ -94,6 +100,9 @@ public class MapFileTileSetIDBroker implements TileSetIDBroker
|
|||||||
/** The next tileset id that we'll assign. */
|
/** The next tileset id that we'll assign. */
|
||||||
protected int _nextTileSetID;
|
protected int _nextTileSetID;
|
||||||
|
|
||||||
|
/** The last tileset id assigned when we were unserialized. */
|
||||||
|
protected int _storedTileSetID;
|
||||||
|
|
||||||
/** Our mapping from tileset names to ids. */
|
/** Our mapping from tileset names to ids. */
|
||||||
protected HashMap _map;
|
protected HashMap _map;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user