Jump to content

Performance question about all the getter functions in Forge classes


treebranch

Recommended Posts

I'm relatively new to Java, and to Forge, and this has been bugging me for a bit. Often times I'll realize I have to call a getter function (e.g. Minecraft.getInstance) every time an event is fired. So to get around this I'll sometimes create a field in the class and set it once. Or in the case of a loop I'll store the value in a local variable and refer back to the variable. I'm used to doing this in languages like C, where optimization and garbage collection isn't exactly the same concept as it is in Java.

 

So my question is, how much of this is necessary? Does it really matter if I call the getter functions a bunch? Does it add any overhead? Memory leaks? Anything? Why are there so many? Sorry if this is more of a Java question. I'm really only using Java for Forge and so the answer will have a significant impact on how I write mods.

 

Thanks ?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.