Skip to content

Commit 1444801

Browse files
jacobsabnoordhuis
authored andcommitted
typed arrays: unexport SizeOfArrayElementForType()
It isn't used anywhere else, so made it an implementation detail in v8_typed_array.cc.
1 parent 16fca26 commit 1444801

2 files changed

Lines changed: 22 additions & 24 deletions

File tree

src/v8_typed_array.cc

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,25 @@ using node::ThrowRangeError;
3333
using node::ThrowTypeError;
3434
using node::ThrowError;
3535

36+
int SizeOfArrayElementForType(v8::ExternalArrayType type) {
37+
switch (type) {
38+
case v8::kExternalByteArray:
39+
case v8::kExternalUnsignedByteArray:
40+
return 1;
41+
case v8::kExternalShortArray:
42+
case v8::kExternalUnsignedShortArray:
43+
return 2;
44+
case v8::kExternalIntArray:
45+
case v8::kExternalUnsignedIntArray:
46+
case v8::kExternalFloatArray:
47+
return 4;
48+
case v8::kExternalDoubleArray:
49+
return 8;
50+
default:
51+
return 0;
52+
}
53+
}
54+
3655
struct BatchedMethods {
3756
const char* name;
3857
v8::Handle<v8::Value> (*func)(const v8::Arguments& args);
@@ -64,7 +83,7 @@ class ArrayBuffer {
6483
v8::Object* obj = v8::Object::Cast(*value);
6584

6685
void* ptr = obj->GetIndexedPropertiesExternalArrayData();
67-
int element_size = v8_typed_array::SizeOfArrayElementForType(
86+
int element_size = SizeOfArrayElementForType(
6887
obj->GetIndexedPropertiesExternalArrayDataType());
6988
int size =
7089
obj->GetIndexedPropertiesExternalArrayDataLength() * element_size;
@@ -699,7 +718,7 @@ class DataView {
699718
unsigned int index = args[0]->Uint32Value();
700719
bool little_endian = args[1]->BooleanValue();
701720
// TODO(deanm): All of these things should be cacheable.
702-
int element_size = v8_typed_array::SizeOfArrayElementForType(
721+
int element_size = SizeOfArrayElementForType(
703722
args.This()->GetIndexedPropertiesExternalArrayDataType());
704723
int size = args.This()->GetIndexedPropertiesExternalArrayDataLength() *
705724
element_size;
@@ -719,7 +738,7 @@ class DataView {
719738
unsigned int index = args[0]->Int32Value();
720739
bool little_endian = args[2]->BooleanValue();
721740
// TODO(deanm): All of these things should be cacheable.
722-
int element_size = v8_typed_array::SizeOfArrayElementForType(
741+
int element_size = SizeOfArrayElementForType(
723742
args.This()->GetIndexedPropertiesExternalArrayDataType());
724743
int size = args.This()->GetIndexedPropertiesExternalArrayDataLength() *
725744
element_size;
@@ -829,25 +848,6 @@ void AttachBindings(v8::Handle<v8::Object> obj) {
829848
DataView::GetTemplate()->GetFunction());
830849
}
831850

832-
int SizeOfArrayElementForType(v8::ExternalArrayType type) {
833-
switch (type) {
834-
case v8::kExternalByteArray:
835-
case v8::kExternalUnsignedByteArray:
836-
return 1;
837-
case v8::kExternalShortArray:
838-
case v8::kExternalUnsignedShortArray:
839-
return 2;
840-
case v8::kExternalIntArray:
841-
case v8::kExternalUnsignedIntArray:
842-
case v8::kExternalFloatArray:
843-
return 4;
844-
case v8::kExternalDoubleArray:
845-
return 8;
846-
default:
847-
return 0;
848-
}
849-
}
850-
851851
} // namespace v8_typed_array
852852

853853
NODE_MODULE(node_typed_array, v8_typed_array::AttachBindings)

src/v8_typed_array.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ namespace v8_typed_array {
2828

2929
void AttachBindings(v8::Handle<v8::Object> obj);
3030

31-
int SizeOfArrayElementForType(v8::ExternalArrayType type);
32-
3331
} // namespace v8_typed_array
3432

3533
#endif // V8_TYPED_ARRAY_H_

0 commit comments

Comments
 (0)