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

Unnecessary check of negative #42

Closed
miurahr opened this issue Oct 2, 2023 · 1 comment
Closed

Unnecessary check of negative #42

miurahr opened this issue Oct 2, 2023 · 1 comment

Comments

@miurahr
Copy link
Contributor

miurahr commented Oct 2, 2023

Hi, I found unnecessary check code in o.t.doublearray.DoubleArray and o.t.doublearray.TailDoubleArray``#getChild method.

   public DoubleArrayNode getChild(char c) {
            int code = charToCode[c];
            if (code == -1) return null;
            int nid = base[nodeId] + code;

Here charToCode is defined char[] and char is ranging from 0x0000 to 0xffff in language specification and never be negative.

I think it can be like

        public DoubleArrayNode getChild(char c) {
            int nid = base[nodeId] + charToCode[c];

I found it when I check the project by SpotBugs, the above code produce an error.

takawitter added a commit that referenced this issue Oct 2, 2023
@takawitter
Copy link
Owner

Thanks again!
I modified the code and added some tests.

@miurahr miurahr closed this as completed Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants