mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Optimize performance by using singletons for items
This commit is contained in:
@@ -98,3 +98,13 @@ export class ColorItem extends BaseItem {
|
||||
context.fill();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton instances
|
||||
* @type {Object<enumColors, ColorItem>}
|
||||
*/
|
||||
export const COLOR_ITEM_SINGLETONS = {};
|
||||
|
||||
for (const color in enumColors) {
|
||||
COLOR_ITEM_SINGLETONS[color] = new ColorItem(color);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ export class ShapeItem extends BaseItem {
|
||||
*/
|
||||
constructor(definition) {
|
||||
super();
|
||||
// logger.log("New shape item for shape definition", definition.generateId(), "created");
|
||||
|
||||
/**
|
||||
* This property must not be modified on runtime, you have to clone the class in order to change the definition
|
||||
|
||||
Reference in New Issue
Block a user