Skip to content

Commit 50724e3

Browse files
BatchProcessor: Fix Class Map
Uses an ObjectMap in place of a Dictionary. I'm not sure if this is better or not. I know Dictionaries have been shown to be quite slow, but we're also working with Dynamic key's here, so it might be in the same boat.
1 parent 4380098 commit 50724e3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/starling/rendering/BatchProcessor.hx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import starling.display.Mesh;
1414
import starling.display.MeshBatch;
1515
import starling.utils.MeshSubset;
1616
import starling.utils.ArrayUtil;
17-
import haxe.ds.Map;
17+
import haxe.ds.ObjectMap;
1818

1919
/** This class manages a list of mesh batches of different types;
2020
* it acts as a "meta" MeshBatch that initiates all rendering.
@@ -183,10 +183,10 @@ class BatchProcessor {
183183
}
184184

185185
class BatchPool {
186-
private var _batchLists:Map<Class<Dynamic>, Array<MeshBatch>>;
186+
private var _batchLists:ObjectMap<Dynamic, Array<MeshBatch>>;
187187

188188
public function new() {
189-
_batchLists = new Map<Class<Dynamic>, Array<MeshBatch>>();
189+
_batchLists = new ObjectMap();
190190
}
191191

192192
public function purge():Void {
@@ -207,10 +207,10 @@ class BatchPool {
207207
}
208208

209209
public function get(styleType:Class<Dynamic>):MeshBatch {
210-
var batchList:Array<MeshBatch> = _batchLists[styleType];
210+
var batchList:Array<MeshBatch> = _batchLists.get(styleType);
211211
if (batchList == null) {
212212
batchList = new Array<MeshBatch>();
213-
_batchLists[styleType] = batchList;
213+
_batchLists.set(styleType, batchList);
214214
}
215215

216216
if (batchList.length > 0)
@@ -221,7 +221,7 @@ class BatchPool {
221221

222222
public function put(meshBatch:MeshBatch):Void {
223223
var styleType:Class<Dynamic> = meshBatch.style.type;
224-
var batchList:Array<MeshBatch> = _batchLists[styleType];
224+
var batchList:Array<MeshBatch> = _batchLists.get(styleType);
225225
if (batchList == null) {
226226
batchList = new Array<MeshBatch>();
227227
_batchLists.set(styleType, batchList);

0 commit comments

Comments
 (0)