employ UserDataHolderEx#putUserDataIfAbsent if available

This commit is contained in:
Gregory.Shrago
2016-10-11 04:55:51 +03:00
parent 2fecb4b0fc
commit 5528e1155b
@@ -15,9 +15,9 @@
*/
package com.intellij.openapi.util;
import com.intellij.util.NotNullFunction;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import com.intellij.util.NotNullFunction;
/**
* @author peter
@@ -38,7 +38,12 @@ public class NotNullLazyKey<T,H extends UserDataHolder> extends Key<T>{
RecursionGuard.StackStamp stamp = ourGuard.markStack();
data = myFunction.fun(h);
if (stamp.mayCacheNow()) {
h.putUserData(this, data);
if (h instanceof UserDataHolderEx) {
data = ((UserDataHolderEx)h).putUserDataIfAbsent(this, data);
}
else {
h.putUserData(this, data);
}
}
}
return data;