# Is there a way to optimize this piece of code?

**URL:** <https://forum.defold.com/t/is-there-a-way-to-optimize-this-piece-of-code/75340>\
**Category:** Questions\
**Created:** [December 15, 2023, 11:44am UTC](https://forum.defold.com/t/is-there-a-way-to-optimize-this-piece-of-code/75340 "2023-12-15T11:44:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [December 15, 2023, 12:55pm UTC](https://forum.defold.com/t/is-there-a-way-to-optimize-this-piece-of-code/75340/2 "2023-12-15T12:55:02Z")

</div>

No. But there might be memory issues with this approach if the number of atlases keeps growing or if they are large. This is discussed here:

> [@How to set atlas property from factory?](https://forum.defold.com/t/how-to-set-atlas-property-from-factory/75331/2):
>
> Interesting problem! If you have hundreds of them you don’t want to use go.property("my\_atlas", resource.atlas("/atlas.atlas")) since all of them will be in memory at once. What I would do is to per atlas create one dummy game object file with a sprite which references the atlas. Each dummy game object is referenced from a factory with the Load Dynamically checkbox set. When you want to use an atlas you load the resources used by the correct factory using factory.load(). This will load the at…

---

_[View the full topic](https://forum.defold.com/t/is-there-a-way-to-optimize-this-piece-of-code/75340)._
