Open
Description
- Flixel version: 3.3.11
- OpenFL version: 3.3.2
- Lime version: 2.6.1
- Affected targets: Android, Flash
Code snippet reproducing the issue:
public function getUniqueKey(?baseKey:String):String
{
if (baseKey == null)
baseKey = "pixels";
if (checkCache(baseKey))
{
var inc:Int = 0;
var ukey:String;
do
{
ukey = baseKey + inc++;
}
while (checkCache(ukey));
baseKey = ukey;
}
return baseKey;
}
I am making a puzzle game in which i am pre-creating 1024 FlxText objects.
Using Timer.stamp(), i was able to figure that each getUniqueKey in FlxText's new function holds around 0.002s, which means the 1024 takes around 2 seconds. It might not be that long but on android and on some low-end tablets, it can be very long.
I don't have a good understanding of how the internals of flixels work or what the next change will imply but here it goes :
public static var LatestInc:Int = 0;
public function getUniqueKey(baseKey:String = "pixels"):String
{
if (checkCache(baseKey))
{
var inc:Int = LatestInc;
var ukey:String;
//ukey = baseKey + LatestInc++;
do
{
ukey = baseKey + inc++;
} while (checkCache(ukey));
LatestInc = inc;
baseKey = ukey;
}
return baseKey;
}
This gave me a 0.3s launch time.
I'm worried that internaly this affects something badly and i won't know it, thus me posting here.
First time posting on github, so...yeah, sorry for any problems or mistakes
Metadata
Metadata
Assignees
Labels
No labels
Activity