Skip to content

Efficiency and better use of API#916

Open
ZenSirzechs wants to merge 1 commit intoCloudburstMC:masterfrom
ZenSirzechs:master
Open

Efficiency and better use of API#916
ZenSirzechs wants to merge 1 commit intoCloudburstMC:masterfrom
ZenSirzechs:master

Conversation

@ZenSirzechs
Copy link
Copy Markdown
Contributor

No description provided.


public static int clamp(int check, int min, int max) {
return check > max ? max : (check < min ? min : check);
return check > max ? max : (Math.max(check, min));
Copy link
Copy Markdown
Member

@SupremeMortal SupremeMortal Nov 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method can be removed since there is an identical one in NukkitMath


public static double clamp(double value, double min, double max) {
return value < min ? min : (value > max ? max : value);
return value < min ? min : (Math.min(value, max));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes more sense to keep the operators in this class.


public static int clamp(int value, int min, int max) {
return value < min ? min : (value > max ? max : value);
return value < min ? min : (Math.min(value, max));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

diffZ = Math.abs(diffZ);

return diffX > diffZ ? diffX : diffZ;
return Math.max(diffX, diffZ);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

switch (this.type) {
case Config.PROPERTIES:
content = this.writeProperties();
content = new StringBuilder(this.writeProperties());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StringBuilder has already been initialised above.

break;
case Config.JSON:
content = new GsonBuilder().setPrettyPrinting().create().toJson(this.config);
content = new StringBuilder(new GsonBuilder().setPrettyPrinting().create().toJson(this.config));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
Yaml yaml = new Yaml(dumperOptions);
content = yaml.dump(this.config);
content = new StringBuilder(yaml.dump(this.config));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants