Skip to content

Commit f2b0fb2

Browse files
addaleaxmmarchini
authored andcommittedMar 23, 2020
src: simplify IsolateData shortcut accesses
PR-URL: nodejs#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]>
1 parent 678e1be commit f2b0fb2

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed
 

‎src/env-inl.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -1276,9 +1276,8 @@ void Environment::set_main_utf16(std::unique_ptr<v8::String::Value> str) {
12761276
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
12771277
#define V(TypeName, PropertyName) \
12781278
inline \
1279-
v8::Local<TypeName> IsolateData::PropertyName(v8::Isolate* isolate) const { \
1280-
/* Strings are immutable so casting away const-ness here is okay. */ \
1281-
return const_cast<IsolateData*>(this)->PropertyName ## _.Get(isolate); \
1279+
v8::Local<TypeName> IsolateData::PropertyName() const { \
1280+
return PropertyName ## _ .Get(isolate_); \
12821281
}
12831282
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
12841283
PER_ISOLATE_SYMBOL_PROPERTIES(VY)
@@ -1293,7 +1292,7 @@ void Environment::set_main_utf16(std::unique_ptr<v8::String::Value> str) {
12931292
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
12941293
#define V(TypeName, PropertyName) \
12951294
inline v8::Local<TypeName> Environment::PropertyName() const { \
1296-
return isolate_data()->PropertyName(isolate()); \
1295+
return isolate_data()->PropertyName(); \
12971296
}
12981297
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
12991298
PER_ISOLATE_SYMBOL_PROPERTIES(VY)

‎src/env.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ IsolateData::IsolateData(Isolate* isolate,
181181

182182
void IsolateData::MemoryInfo(MemoryTracker* tracker) const {
183183
#define V(PropertyName, StringValue) \
184-
tracker->TrackField(#PropertyName, PropertyName(isolate()));
184+
tracker->TrackField(#PropertyName, PropertyName());
185185
PER_ISOLATE_SYMBOL_PROPERTIES(V)
186186
#undef V
187187

188188
#define V(PropertyName, StringValue) \
189-
tracker->TrackField(#PropertyName, PropertyName(isolate()));
189+
tracker->TrackField(#PropertyName, PropertyName());
190190
PER_ISOLATE_STRING_PROPERTIES(V)
191191
#undef V
192192

‎src/env.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ class IsolateData : public MemoryRetainer {
503503
#define VY(PropertyName, StringValue) V(v8::Symbol, PropertyName)
504504
#define VS(PropertyName, StringValue) V(v8::String, PropertyName)
505505
#define V(TypeName, PropertyName) \
506-
inline v8::Local<TypeName> PropertyName(v8::Isolate* isolate) const;
506+
inline v8::Local<TypeName> PropertyName() const;
507507
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(VP)
508508
PER_ISOLATE_SYMBOL_PROPERTIES(VY)
509509
PER_ISOLATE_STRING_PROPERTIES(VS)

0 commit comments

Comments
 (0)