RFR: 8288140: Avoid redundant Hashtable.get call in Signal.handle [v2]
David M. Lloyd
duke at openjdk.java.net
Fri Jun 10 11:49:06 UTC 2022
On Fri, 10 Jun 2022 06:45:00 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/misc/Signal.java line 180:
>>
>>> 178: if (newH == 2) {
>>> 179: handlers.put(sig, handler);
>>> 180: }
>>
>> If you made this change instead:
>>
>> Suggestion:
>>
>> Signal.Handler oldHandler;
>> if (newH == 2) {
>> oldHandler = handlers.put(sig, handler);
>> } else {
>> oldHandler = handlers.remove(sig);
>> }
>>
>>
>> Wouldn't you be able to remove the entire `synchronized` block?
>
> Hello David, I suspect you mean `handlers.put(sig, handler)` and not `handlers.replace(...)`? And yes, I think what you suggest will help remove the synchronized block here.
Oops, yes you are correct!
-------------
PR: https://git.openjdk.org/jdk/pull/9100
More information about the core-libs-dev
mailing list