Skip to main content
markdown fix
Source Link
janos
  • 111.7k
  • 15
  • 152
  • 391

First of all: It's never a bad idea to explain what you want your code to do since it does help everyone involved. It often helps understanding a certain problem better by explaining it to other people, and the community on here will have a much easier time reviewing your code when knowing what your goal is.

Regarding your question: Reading the documentation about the tools that you're using can benefit you a lot, in this case Maps. In the documentation it says that the left row of the Map contains the key, which can not have any duplicates. Since you are using String literals as keys your map will always be completely overridden once your convToPosfixQueue()-methodconvToPosfixQueue() method gets called, thus making the generation of this map for every method call unnecessary.

It won't be that relevant if you're aiming to maximize your performance, but it is good practice.

First of all: It's never a bad idea to explain what you want your code to do since it does help everyone involved. It often helps understanding a certain problem better by explaining it to other people, and the community on here will have a much easier time reviewing your code when knowing what your goal is.

Regarding your question: Reading the documentation about the tools that you're using can benefit you a lot, in this case Maps. In the documentation it says that the left row of the Map contains the key, which can not have any duplicates. Since you are using String literals as keys your map will always be completely overridden once your convToPosfixQueue()-method gets called, thus making the generation of this map for every method call unnecessary.

It won't be that relevant if you're aiming to maximize your performance, but it is good practice.

First of all: It's never a bad idea to explain what you want your code to do since it does help everyone involved. It often helps understanding a certain problem better by explaining it to other people, and the community on here will have a much easier time reviewing your code when knowing what your goal is.

Regarding your question: Reading the documentation about the tools that you're using can benefit you a lot, in this case Maps. In the documentation it says that the left row of the Map contains the key, which can not have any duplicates. Since you are using String literals as keys your map will always be completely overridden once your convToPosfixQueue() method gets called, thus making the generation of this map for every method call unnecessary.

It won't be that relevant if you're aiming to maximize your performance, but it is good practice.

Source Link
Seth
  • 111
  • 3

First of all: It's never a bad idea to explain what you want your code to do since it does help everyone involved. It often helps understanding a certain problem better by explaining it to other people, and the community on here will have a much easier time reviewing your code when knowing what your goal is.

Regarding your question: Reading the documentation about the tools that you're using can benefit you a lot, in this case Maps. In the documentation it says that the left row of the Map contains the key, which can not have any duplicates. Since you are using String literals as keys your map will always be completely overridden once your convToPosfixQueue()-method gets called, thus making the generation of this map for every method call unnecessary.

It won't be that relevant if you're aiming to maximize your performance, but it is good practice.