Skip to content

Commit

Permalink
src: simplify IsolateData shortcut accesses
Browse files Browse the repository at this point in the history
PR-URL: #32407
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matheus Marchini <[email protected]>
  • Loading branch information
addaleax authored and mmarchini committed Mar 23, 2020
1 parent 678e1be commit f2b0fb2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1276,9 +1276,8 @@ void Environment::set_main_utf16(std::unique_ptr<v8::String::Value> str) {
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
#define V(TypeName, PropertyName) \
inline \
v8::Local<TypeName> IsolateData::PropertyName(v8::Isolate* isolate) const { \
/* Strings are immutable so casting away const-ness here is okay. */ \
return const_cast<IsolateData*>(this)->PropertyName ## _.Get(isolate); \
v8::Local<TypeName> IsolateData::PropertyName() const { \
return PropertyName ## _ .Get(isolate_); \
}
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
PER_ISOLATE_SYMBOL_PROPERTIES(VY)
Expand All @@ -1293,7 +1292,7 @@ void Environment::set_main_utf16(std::unique_ptr<v8::String::Value> str) {
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
#define V(TypeName, PropertyName) \
inline v8::Local<TypeName> Environment::PropertyName() const { \
return isolate_data()->PropertyName(isolate()); \
return isolate_data()->PropertyName(); \
}
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
PER_ISOLATE_SYMBOL_PROPERTIES(VY)
Expand Down
4 changes: 2 additions & 2 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ IsolateData::IsolateData(Isolate* isolate,

void IsolateData::MemoryInfo(MemoryTracker* tracker) const {
#define V(PropertyName, StringValue) \
tracker->TrackField(#PropertyName, PropertyName(isolate()));
tracker->TrackField(#PropertyName, PropertyName());
PER_ISOLATE_SYMBOL_PROPERTIES(V)
#undef V

#define V(PropertyName, StringValue) \
tracker->TrackField(#PropertyName, PropertyName(isolate()));
tracker->TrackField(#PropertyName, PropertyName());
PER_ISOLATE_STRING_PROPERTIES(V)
#undef V

Expand Down
2 changes: 1 addition & 1 deletion src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ class IsolateData : public MemoryRetainer {
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
#define V(TypeName, PropertyName) \
inline v8::Local<TypeName> PropertyName(v8::Isolate* isolate) const;
inline v8::Local<TypeName> PropertyName() const;
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
PER_ISOLATE_SYMBOL_PROPERTIES(VY)
PER_ISOLATE_STRING_PROPERTIES(VS)
Expand Down

0 comments on commit f2b0fb2

Please sign in to comment.