@@ -22,19 +22,19 @@ typedef size_t AliasedBufferIndex;
22
22
*
23
23
* While this technique is computationally efficient, it is effectively a
24
24
* write to JS program state w/out going through the standard
25
- * (monitored) API. Thus any VM capabilities to detect the modification are
25
+ * (monitored) API. Thus, any VM capabilities to detect the modification are
26
26
* circumvented.
27
27
*
28
28
* The encapsulation herein provides a placeholder where such writes can be
29
29
* observed. Any notification APIs will be left as a future exercise.
30
30
*/
31
31
template <class NativeT , class V8T >
32
- class AliasedBufferBase : public MemoryRetainer {
32
+ class AliasedBufferBase final : public MemoryRetainer {
33
33
public:
34
- static_assert (std::is_scalar <NativeT>::value );
34
+ static_assert (std::is_scalar_v <NativeT>);
35
35
36
36
AliasedBufferBase (v8::Isolate* isolate,
37
- const size_t count,
37
+ size_t count,
38
38
const AliasedBufferIndex* index = nullptr );
39
39
40
40
/* *
@@ -43,13 +43,13 @@ class AliasedBufferBase : public MemoryRetainer {
43
43
* a native buffer, but will each read/write to different sections of the
44
44
* native buffer.
45
45
*
46
- * Note that byte_offset must by aligned by sizeof(NativeT).
46
+ * Note that byte_offset must be aligned by sizeof(NativeT).
47
47
*/
48
48
// TODO(refack): refactor into a non-owning `AliasedBufferBaseView`
49
49
AliasedBufferBase (
50
50
v8::Isolate* isolate,
51
- const size_t byte_offset,
52
- const size_t count,
51
+ size_t byte_offset,
52
+ size_t count,
53
53
const AliasedBufferBase<uint8_t , v8::Uint8Array>& backing_buffer,
54
54
const AliasedBufferIndex* index = nullptr );
55
55
@@ -58,7 +58,7 @@ class AliasedBufferBase : public MemoryRetainer {
58
58
AliasedBufferIndex Serialize (v8::Local<v8::Context> context,
59
59
v8::SnapshotCreator* creator);
60
60
61
- inline void Deserialize (v8::Local<v8::Context> context);
61
+ void Deserialize (v8::Local<v8::Context> context);
62
62
63
63
AliasedBufferBase& operator =(AliasedBufferBase&& that) noexcept ;
64
64
@@ -68,45 +68,45 @@ class AliasedBufferBase : public MemoryRetainer {
68
68
*/
69
69
class Reference {
70
70
public:
71
- Reference (AliasedBufferBase<NativeT, V8T> * aliased_buffer, size_t index)
71
+ Reference (AliasedBufferBase* aliased_buffer, const size_t index)
72
72
: aliased_buffer_(aliased_buffer), index_(index) {}
73
73
74
74
Reference (const Reference& that)
75
75
: aliased_buffer_(that.aliased_buffer_),
76
76
index_ (that.index_) {
77
77
}
78
78
79
- inline Reference& operator =(const NativeT& val) {
79
+ Reference& operator =(const NativeT& val) {
80
80
aliased_buffer_->SetValue (index_, val);
81
81
return *this ;
82
82
}
83
83
84
- inline Reference& operator =(const Reference& val) {
84
+ Reference& operator =(const Reference& val) {
85
85
return *this = static_cast <NativeT>(val);
86
86
}
87
87
88
88
operator NativeT () const {
89
89
return aliased_buffer_->GetValue (index_);
90
90
}
91
91
92
- inline Reference& operator +=(const NativeT& val) {
92
+ Reference& operator +=(const NativeT& val) {
93
93
const NativeT current = aliased_buffer_->GetValue (index_);
94
94
aliased_buffer_->SetValue (index_, current + val);
95
95
return *this ;
96
96
}
97
97
98
- inline Reference& operator +=(const Reference& val) {
98
+ Reference& operator +=(const Reference& val) {
99
99
return this ->operator +=(static_cast <NativeT>(val));
100
100
}
101
101
102
- inline Reference& operator -=(const NativeT& val) {
102
+ Reference& operator -=(const NativeT& val) {
103
103
const NativeT current = aliased_buffer_->GetValue (index_);
104
104
aliased_buffer_->SetValue (index_, current - val);
105
105
return *this ;
106
106
}
107
107
108
108
private:
109
- AliasedBufferBase<NativeT, V8T> * aliased_buffer_;
109
+ AliasedBufferBase* aliased_buffer_;
110
110
size_t index_;
111
111
};
112
112
@@ -123,7 +123,7 @@ class AliasedBufferBase : public MemoryRetainer {
123
123
* array becomes unreachable. Usually this means the caller must maintain
124
124
* a JS reference to the typed array from JS object.
125
125
*/
126
- inline void MakeWeak ();
126
+ void MakeWeak ();
127
127
128
128
/* *
129
129
* Get the underlying v8::ArrayBuffer underlying the TypedArray and
@@ -135,22 +135,22 @@ class AliasedBufferBase : public MemoryRetainer {
135
135
* Get the underlying native buffer. Note that all reads/writes should occur
136
136
* through the GetValue/SetValue/operator[] methods
137
137
*/
138
- inline const NativeT* GetNativeBuffer () const ;
138
+ const NativeT* GetNativeBuffer () const ;
139
139
140
140
/* *
141
141
* Synonym for GetBuffer()
142
142
*/
143
- inline const NativeT* operator *() const ;
143
+ const NativeT* operator *() const ;
144
144
145
145
/* *
146
146
* Set position index to given value.
147
147
*/
148
- inline void SetValue (const size_t index, NativeT value);
148
+ void SetValue (size_t index, NativeT value);
149
149
150
150
/* *
151
151
* Get value at position index
152
152
*/
153
- inline const NativeT GetValue (const size_t index) const ;
153
+ const NativeT GetValue (size_t index) const ;
154
154
155
155
/* *
156
156
* Effectively, a synonym for GetValue/SetValue
@@ -166,13 +166,13 @@ class AliasedBufferBase : public MemoryRetainer {
166
166
// an owning `AliasedBufferBase`.
167
167
void reserve (size_t new_capacity);
168
168
169
- inline size_t SelfSize () const override ;
169
+ size_t SelfSize () const override ;
170
170
171
- inline const char * MemoryInfoName () const override ;
172
- inline void MemoryInfo (node:: MemoryTracker* tracker) const override ;
171
+ const char * MemoryInfoName () const override ;
172
+ void MemoryInfo (MemoryTracker* tracker) const override ;
173
173
174
174
private:
175
- inline bool is_valid () const ;
175
+ bool is_valid () const ;
176
176
v8::Isolate* isolate_ = nullptr ;
177
177
size_t count_ = 0 ;
178
178
size_t byte_offset_ = 0 ;
0 commit comments