Skip to content

Commit

Permalink
BatchProcessor: Fix Class Map
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Dimensionscape committed Jul 10, 2024
1 parent 4380098 commit 50724e3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/starling/rendering/BatchProcessor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import starling.display.Mesh;
import starling.display.MeshBatch;
import starling.utils.MeshSubset;
import starling.utils.ArrayUtil;
import haxe.ds.Map;
import haxe.ds.ObjectMap;

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

class BatchPool {
private var _batchLists:Map<Class<Dynamic>, Array<MeshBatch>>;
private var _batchLists:ObjectMap<Dynamic, Array<MeshBatch>>;

public function new() {
_batchLists = new Map<Class<Dynamic>, Array<MeshBatch>>();
_batchLists = new ObjectMap();
}

public function purge():Void {
Expand All @@ -207,10 +207,10 @@ class BatchPool {
}

public function get(styleType:Class<Dynamic>):MeshBatch {
var batchList:Array<MeshBatch> = _batchLists[styleType];
var batchList:Array<MeshBatch> = _batchLists.get(styleType);
if (batchList == null) {
batchList = new Array<MeshBatch>();
_batchLists[styleType] = batchList;
_batchLists.set(styleType, batchList);
}

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

public function put(meshBatch:MeshBatch):Void {
var styleType:Class<Dynamic> = meshBatch.style.type;
var batchList:Array<MeshBatch> = _batchLists[styleType];
var batchList:Array<MeshBatch> = _batchLists.get(styleType);
if (batchList == null) {
batchList = new Array<MeshBatch>();
_batchLists.set(styleType, batchList);
Expand Down

0 comments on commit 50724e3

Please sign in to comment.