Skip to content

Commit c6508f7

Browse files
author
Mike Kaufman
committed
respnoding to PR feedback
1 parent d06a833 commit c6508f7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/aliased_buffer.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,17 @@ class AliasedBuffer {
6565
byte_offset_(byte_offset),
6666
free_buffer_(false) {
6767
const v8::HandleScope handle_scope(isolate_);
68+
69+
v8::Local<v8::ArrayBuffer> ab = backing_buffer.GetArrayBuffer();
70+
6871
// validate that the byte_offset is aligned with sizeof(NativeT)
6972
CHECK_EQ(byte_offset & (sizeof(NativeT) - 1), 0);
7073
// 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);
7375

7476
buffer_ = reinterpret_cast<NativeT*>(
7577
const_cast<uint8_t*>(backing_buffer.GetNativeBuffer() + byte_offset));
7678

77-
v8::Local<v8::ArrayBuffer> ab = backing_buffer.GetArrayBuffer();
7879
v8::Local<V8T> js_array = V8T::New(ab, byte_offset, count);
7980
js_array_ = v8::Global<V8T>(isolate, js_array);
8081
}
@@ -159,19 +160,19 @@ class AliasedBuffer {
159160
* Set position index to given value.
160161
*/
161162
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
165166
buffer_[index] = value;
166167
}
167168

168169
/**
169170
* Get value at position index
170171
*/
171172
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
175176
return buffer_[index];
176177
}
177178

0 commit comments

Comments
 (0)