Skip to content

Instantly share code, notes, and snippets.

@Constellation
Created September 10, 2016 06:21
Show Gist options
  • Select an option

  • Save Constellation/23875cad25d90908f15a4380501a95a2 to your computer and use it in GitHub Desktop.

Select an option

Save Constellation/23875cad25d90908f15a4380501a95a2 to your computer and use it in GitHub Desktop.
#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