Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Efficiency and better use of API #916

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Efficiency and better use of API #916

wants to merge 1 commit into from

Conversation

ZenSirzechs
Copy link
Contributor

No description provided.

@@ -92,7 +92,7 @@ public static int ceil(float floatNumber) {
}

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
Member

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

@@ -47,18 +47,18 @@ public static double round(double d, int precision) {
}

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
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
Member

Choose a reason for hiding this comment

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

Same here

}

public static double getDirection(double diffX, double diffZ) {
diffX = Math.abs(diffX);
diffZ = Math.abs(diffZ);

return diffX > diffZ ? diffX : diffZ;
return Math.max(diffX, diffZ);
Copy link
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
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
Member

Choose a reason for hiding this comment

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

Same here

break;
case Config.YAML:
DumperOptions dumperOptions = new DumperOptions();
dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
Yaml yaml = new Yaml(dumperOptions);
content = yaml.dump(this.config);
content = new StringBuilder(yaml.dump(this.config));
Copy link
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.

None yet

2 participants