@@ -65,16 +65,17 @@ class AliasedBuffer {
65
65
byte_offset_(byte_offset),
66
66
free_buffer_(false ) {
67
67
const v8::HandleScope handle_scope (isolate_);
68
+
69
+ v8::Local<v8::ArrayBuffer> ab = backing_buffer.GetArrayBuffer ();
70
+
68
71
// validate that the byte_offset is aligned with sizeof(NativeT)
69
72
CHECK_EQ (byte_offset & (sizeof (NativeT) - 1 ), 0 );
70
73
// validate this fits inside the backing buffer
71
- CHECK_LE (sizeof (NativeT) * count,
72
- backing_buffer.GetArrayBuffer ()->ByteLength () - byte_offset);
74
+ CHECK_LE (sizeof (NativeT) * count, ab->ByteLength () - byte_offset);
73
75
74
76
buffer_ = reinterpret_cast <NativeT*>(
75
77
const_cast <uint8_t *>(backing_buffer.GetNativeBuffer () + byte_offset));
76
78
77
- v8::Local<v8::ArrayBuffer> ab = backing_buffer.GetArrayBuffer ();
78
79
v8::Local<V8T> js_array = V8T::New (ab, byte_offset, count);
79
80
js_array_ = v8::Global<V8T>(isolate, js_array);
80
81
}
@@ -159,19 +160,19 @@ class AliasedBuffer {
159
160
* Set position index to given value.
160
161
*/
161
162
inline void SetValue (const size_t index, NativeT value) {
162
- #if defined(DEBUG) && DEBUG
163
- CHECK_LT (index, count_);
164
- #endif
163
+ #if defined(DEBUG) && DEBUG
164
+ CHECK_LT (index, count_);
165
+ #endif
165
166
buffer_[index] = value;
166
167
}
167
168
168
169
/* *
169
170
* Get value at position index
170
171
*/
171
172
inline const NativeT GetValue (const size_t index) const {
172
- #if defined(DEBUG) && DEBUG
173
- CHECK_LT (index, count_);
174
- #endif
173
+ #if defined(DEBUG) && DEBUG
174
+ CHECK_LT (index, count_);
175
+ #endif
175
176
return buffer_[index];
176
177
}
177
178
0 commit comments