-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
De-dupe gradient stops #2081
De-dupe gradient stops #2081
Conversation
float[] merged = new float[mergedNotTruncated.length - numDuplicates]; | ||
System.arraycopy(mergedNotTruncated, 0, merged, 0, merged.length); | ||
return merged; |
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.
nit:
float[] merged = new float[mergedNotTruncated.length - numDuplicates]; | |
System.arraycopy(mergedNotTruncated, 0, merged, 0, merged.length); | |
return merged; | |
return Arrays.copyOf(mergedNotTruncated, mergedNotTruncated.lengh - numDuplicates); |
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.
Done!
} | ||
|
||
if (Float.isNaN(b) || a < b) { | ||
mergedNotTruncated[mergedIndex++] = a; |
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 mergeIndex
can be replaced by i
?
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.
Yup!
final float a; | ||
if (aIndex < arrayA.length) { | ||
a = arrayA[aIndex]; | ||
} else { | ||
a = Float.NaN; | ||
} |
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.
nit could be elvis
final float a; | |
if (aIndex < arrayA.length) { | |
a = arrayA[aIndex]; | |
} else { | |
a = Float.NaN; | |
} | |
final float a = aIndex < arrayA.length ? arrayA[aIndex] : Float.NaN |
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.
👍
@gpeal @denis-bezrukov This can theoretically be simply fixed not to crash, but I believe that would completely break the intended gradient animation. If the problem solved by this PR was needed mostly for static lottie files, maybe you could apply this change only when parsing a static value: |
@imbryk Could you attach an animation that is crashing? I'd rather fix the problem than fall back to something wrong. |
@gpeal would it be possible to send it to you privately? |
@imbryk Yeah, go ahead and DM it to me on Twitter but open a new issue saying you did that so it doesn't slip through the cracks the next time I work on this. |
@gpeal I am not able to send you a message on twitter 🤷 - please grab the files from gdrive: |
Refer to code comments for more info:
Before:
After: