[v3.8.6] Add freezeColor internal method to reduce code size.#18162
Conversation
👍 Package size ⤵ -136 bytes, old: 5270176, new: 5270040Interface Check ReportThis pull request does not change any public interfaces ! |
| public static BLUE = freezeColor(0, 0, 255, 255); | ||
| public static CYAN = freezeColor(0, 255, 255, 255); | ||
| public static MAGENTA = freezeColor(255, 0, 255, 255); | ||
| public static YELLOW = freezeColor(255, 255, 0, 255); |
There was a problem hiding this comment.
Can just assign Object.freeze to a variable? Such as
const freezeColor = Object.freeze;
There was a problem hiding this comment.
Probably we could, I didn't test that.
This depends on whether the implementation of Object.freeze uses this object since we change this object by const freezeColor = Object.freeze.
For safety, it's better to use const freezeColor = Object.freeze.bind(Object);.
There was a problem hiding this comment.
After thinking a while, I think we should not use const freezeColor = Object.freeze since that will generate more code.
public static BLUE = freezeColor(new Color(0, 0, 255, 255)); will be mangled to
Color.BLUE = aa(new Color(0, 0, 255, 255));
while using function
public static BLUE = freezeColor(0, 0, 255, 255);will be mangled to
Color.BLUE = aa(0, 0, 255, 255); // shorter and without new Color(...)
Re: #
Changelog
Continuous Integration
This pull request:
Compatibility Check
This pull request: