fury
fury copied to clipboard
refactor(java): [Don't Merge for Now]Modify the current memory manipulation to be compatible with Android
What does this PR do?
This commit refactors memory management logic as an initial step towards making the project compatible with the Android platform.
Key points:
- This is an exploratory change to propose a potential solution. The design may require further refinement for clarity.
- These changes are strictly limited to memory operations. Full Android support will require other modifications.
- Detailed documentation explaining the rationale will be provided later.
Related issues
- #2435
Does this PR introduce any user-facing change?
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
Benchmark
Andriod String seems be implemented as a native class, we can't get value and coder field from String object.
Here are two tricks to keep maxmimal performance:
- Use
public void getBytes (int srcBegin, int srcEnd, byte[] dst, int dstBegin)to get bytes forJDK9+ - Use
String.toCharArrayfor JDK8
Don't use String.charAt, it's much more slow than get chars array first and check by a loop. JVM can employ some optimzation for simple loops if it doesn't contains nested methods call