-
Notifications
You must be signed in to change notification settings - Fork 48
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
Small improvements #10
base: experimental
Are you sure you want to change the base?
Conversation
The streams created using Files methods are usually more efficient than those created by stream constructors.
// moving. | ||
this.wasWithinPropWindow = false; | ||
} | ||
// If this happens, the unit is facing the wrong way, and has to turn before |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the proposed change, the meaning of this comment becomes somewhat lost or perhaps misleading. Would be nice to fix this so that if there is going to be a comment, it continues to be meaningful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the comment in 645cc15.
@@ -8,7 +8,7 @@ | |||
import java.util.regex.Pattern; | |||
|
|||
public class IniFile { | |||
private static final Pattern NAME_PATTERN = Pattern.compile("^\\[(.+?)\\].*"); | |||
private static final Pattern NAME_PATTERN = Pattern.compile("^\\[(.+?)].*"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the readme, this pattern (and indeed this entire file) is a near-direct copy of:
https://github.com/flowtsohg/mdx-m3-viewer/blob/0162f72ce23a07975764000d7225b7295d7bc460/src/parsers/ini/file.ts#L25
Is there value to distancing ourselves from the original regex over something so pedantic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the only reason for this change was to make it simpler. But, I think, you are right, as this is basically a copy from another place, we can skip it and maybe revisit it and similar parts in the future if needed. I will revert the commit with this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted in 7c893a4.
@@ -84,13 +84,8 @@ else if (!this.gameInstallPath.equals(other.gameInstallPath)) { | |||
return false; | |||
} | |||
if (this.prefixes == null) { | |||
if (other.prefixes != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method was computer generated by my IDE. If we change it, then I generate another similar method later, they will become needlessly different. What do we propose as a good solution to this dilemma? Ideally, all the computer generated methods will end up the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different IDEs are generating the same methods differently. And, of course, we cannot force everyone to use the same IDE. The possible solution may be to try to use Lombok or something similar to eliminate the boilerplate code. Also, in that case, we will not be forced to change the autogenerated code every time when we are adding, changing or deleting fields. Meanwhile, I will revert this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted in 6612bf8.
if (this.count >= countLimit) { | ||
return true; | ||
} | ||
return this.count >= countLimit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (this.southeast.intersect(bounds, intersector)) { | ||
return true; | ||
} | ||
return this.southeast.intersect(bounds, intersector); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this an exceedingly pedantic automated change the interrupts the original style of the code where there were four identical branches that could be easily observed by a developer to be the same (see image for how this code looked on my PC before the change):
Certainly it is correct either way, but if we were ever going to modify this Quadtree to make an Octtree for example, and copy this to have eight branches instead of four, having one of the branches be needlessly different in order to pedantically avoid "if {x} return" syntax seems pointless from my perspective. Curious to hear your opinion or if there's a good reason in favor of changing it that I'm just not seeing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you, having one of the branches be needlessly different in order to pedantically avoid "if {x} return" syntax is pointless. Please check 60abd00, where are refactored Quadtree.java.
return false; | ||
} | ||
return true; | ||
return !(Math.abs(other.w - this.w) > epsilon); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Similar case to the Quadtree comment.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check 60abd00, where I refactored Vector4.java.
case FLOAT: | ||
return this.groundUnitCollision.intersect(newPossibleRectangle, | ||
this.anyUnitExceptTwoIntersector.reset(sourceUnitToIgnore, sourceSecondUnitToIgnore)); | ||
case FLOAT: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again it appears that the automatic format indentation here for case FLOAT:
does not match all other indentation of all other case statements in this file. When we are going far out of our way to be pedantic, I think we should update cases like this to match the code around them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the formatting, added some more small changes in 57b2b04.
Hey! Above I added some review comments. From what I can tell, it seems that you ran an autoformatter on this codebase, but using format style settings that are different than the autoformatter that I had setup in my IDE to run on the code constantly while I was writing it. Do you have a reference point or IDE formatter settings that would cause future author contributions to be consistent with the automatic format you are suggesting here? |
I think a good idea would be having a intellij code style file in the repo and collectively sticking to it to minimize formatting commits. Even if it's the default intellij style. |
@Retera |
Yes, agree. Even if not the completely default codestyle of Intellij Idea or some other one, it will be still helpful to have it in repository. Especially in case, when people are using different IDEs. |
@Retera does it makes sense to squash all this into 1 commit? GIthub may have that funcitonality by now if you wanna go that way |
@Retera Any chance this PR can be merged? |
Hey, sorry it's been a while on this. Prior to merging I would like to make sure that I read through each and every line that changed again. It may sound like a sort of personal problem on my part, but in the past I had contributions from other authors in a different open source project that I cared about greatly where I took for granted that the contributors also cared and I did not carefully read their contributions. Eventually it became a code soup so horrendous that I branched off of the version from before their pull requests and stopped following the main branch because I simply did not have time to reconcile their changes against the original intention of the program. When we do something like an extensive automatic reformat, that increases the amount of work for me to do reviewing and I have had it at the back of my mind to take a look at that for sure, but I just haven't gotten around to it yet. In the meantime until I get around to that, if you happen to have any specific gameplay needs for the game engine, feel free to make a pull request for specific features that I might be able to review more quickly and maybe I'll be able to get that done sooner. For example, I was on a call with the user CanFight and you may have seen he made a tiny pull request that changed like 6 or so lines to add "Grid" hotkeys, and because I was talking to him (watching him type the code at the time via the screenshare call), I was able to approve that pull request very quickly because it was much faster for me to review. |
@Retera Hi, may it will be easier for you, if we will start with single file scope pull requests? |
Sure. That seemed to be working for other recent pull requests by bearU369. It creates less for me to look through, so I can get through it more quickly. |
Remove redundant character escape
Remove redundant 'if' statement
Remove redundant 'else'
Remove redundant 'new' expression in constant array creation
Remove redundant 'File' instance creation
Change C-style array declarations to Java-style array declarations
Sort missorted modifiers
Replace 'size() == 0' with 'isEmpty()'
Remove redundant field initialization
Remove unnecessary call to 'toString()'
Remove unnecessary conversion to String
Replace 'String.equals()' with 'String.isEmpty()'
Use Files.newInputStream() and Files.newOutputStream()
Remove unnecessary concatenation with empty string
Replace manual array to collection copy with 'addAll()'
Some other changes and cleanup