Created
September 10, 2016 06:21
-
-
Save Constellation/23875cad25d90908f15a4380501a95a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define JSDynamicCast(To) \ | |
| [] (auto from) -> To { \ | |
| static thread_local const JSC::ClassInfo* cache = nullptr; \ | |
| auto* classInfo = extractClassInfo(from); \ | |
| if (UNLIKELY(!classInfo)) \ | |
| return nullptr; \ | |
| if (classInfo == cache) \ | |
| return JSC::jsCast<To>(from); \ | |
| auto* result = JSC::jsDynamicCast<To>(from); \ | |
| if (result) \ | |
| cache = classInfo; \ | |
| return result; \ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment