<html><body><div dir="ltr"><div>
</div><div><div>
<div>Or maybe make it more generic and allow to specify the base as well, that’s more along the line of existing toString() methods of numbers.</div><div dir="ltr"><br></div><div dir="ltr">besides convinience, I wonder if it would actually improve performance, how good is the JIT and EA in that case, did you run some benchmarks?</div><div dir="ltr"><br></div><div dir="ltr">Gruss</div><div dir="ltr">Bernd</div><div id="ms-outlook-mobile-signature"><div style="direction:ltr">-- </div><div style="direction:ltr">http://bernd.eckenfels.net</div></div>
</div>
<div> </div><hr style="display:inline-block;width:98%" tabindex="-1"><div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif"><b>Von:</b> core-libs-dev <core-libs-dev-retn@openjdk.org> im Auftrag von 温绍锦(高铁) <shaojin.wensj@alibaba-inc.com><br><b>Gesendet:</b> Samstag, September 30, 2023 2:07 PM<br><b>An:</b> core-libs-dev <core-libs-dev@openjdk.org><br><b>Betreff:</b> Adding appendHex method to StringBuilder<div> </div></font></div><div class="__aliyun_email_body_block"><div style="line-height: 1.7; font-family: Tahoma, Arial, STHeiti, SimSun; font-size: 14px; color: rgb(0, 112, 192);"><div style="clear:both">There are many combinations of `append(Integer.toHexString(i))` and `append(Long.toHexString(i))` in the JDK code. I request to add method `appendHex(int)` and `appendHex(int)` to StringBuilder and StringBuffer. This can reduce duplicate code within the JDK and will also be useful to users.<br></div><div style="line-height:20.0px; clear:both"><div style="clear:both"><br></div><div style="clear:both">I submitted a PR ( <a href="https://github.com/openjdk/jdk/pull/15998">https://github.com/openjdk/jdk/pull/15998</a> ), including the code and tests for the new method. I also replaced the code that uses the append + toHexString combination inside the JDK with appendHex.</div><span><div style="line-height:20.0px; clear:both"><span><br></span></div>Please review and don't hesitate to critique my approach and patch.</span></div></div></div></div></div></body></html>