Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
typed arrays: unexport SizeOfArrayElementForType()
Browse files Browse the repository at this point in the history
It isn't used anywhere else, so made it an implementation detail in
v8_typed_array.cc.
  • Loading branch information
jacobsa authored and bnoordhuis committed Apr 12, 2012
1 parent 16fca26 commit 1444801
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
44 changes: 22 additions & 22 deletions src/v8_typed_array.cc
Expand Up @@ -33,6 +33,25 @@ using node::ThrowRangeError;
using node::ThrowTypeError;
using node::ThrowError;

int SizeOfArrayElementForType(v8::ExternalArrayType type) {
switch (type) {
case v8::kExternalByteArray:
case v8::kExternalUnsignedByteArray:
return 1;
case v8::kExternalShortArray:
case v8::kExternalUnsignedShortArray:
return 2;
case v8::kExternalIntArray:
case v8::kExternalUnsignedIntArray:
case v8::kExternalFloatArray:
return 4;
case v8::kExternalDoubleArray:
return 8;
default:
return 0;
}
}

struct BatchedMethods {
const char* name;
v8::Handle<v8::Value> (*func)(const v8::Arguments& args);
Expand Down Expand Up @@ -64,7 +83,7 @@ class ArrayBuffer {
v8::Object* obj = v8::Object::Cast(*value);

void* ptr = obj->GetIndexedPropertiesExternalArrayData();
int element_size = v8_typed_array::SizeOfArrayElementForType(
int element_size = SizeOfArrayElementForType(
obj->GetIndexedPropertiesExternalArrayDataType());
int size =
obj->GetIndexedPropertiesExternalArrayDataLength() * element_size;
Expand Down Expand Up @@ -699,7 +718,7 @@ class DataView {
unsigned int index = args[0]->Uint32Value();
bool little_endian = args[1]->BooleanValue();
// TODO(deanm): All of these things should be cacheable.
int element_size = v8_typed_array::SizeOfArrayElementForType(
int element_size = SizeOfArrayElementForType(
args.This()->GetIndexedPropertiesExternalArrayDataType());
int size = args.This()->GetIndexedPropertiesExternalArrayDataLength() *
element_size;
Expand All @@ -719,7 +738,7 @@ class DataView {
unsigned int index = args[0]->Int32Value();
bool little_endian = args[2]->BooleanValue();
// TODO(deanm): All of these things should be cacheable.
int element_size = v8_typed_array::SizeOfArrayElementForType(
int element_size = SizeOfArrayElementForType(
args.This()->GetIndexedPropertiesExternalArrayDataType());
int size = args.This()->GetIndexedPropertiesExternalArrayDataLength() *
element_size;
Expand Down Expand Up @@ -829,25 +848,6 @@ void AttachBindings(v8::Handle<v8::Object> obj) {
DataView::GetTemplate()->GetFunction());
}

int SizeOfArrayElementForType(v8::ExternalArrayType type) {
switch (type) {
case v8::kExternalByteArray:
case v8::kExternalUnsignedByteArray:
return 1;
case v8::kExternalShortArray:
case v8::kExternalUnsignedShortArray:
return 2;
case v8::kExternalIntArray:
case v8::kExternalUnsignedIntArray:
case v8::kExternalFloatArray:
return 4;
case v8::kExternalDoubleArray:
return 8;
default:
return 0;
}
}

} // namespace v8_typed_array

NODE_MODULE(node_typed_array, v8_typed_array::AttachBindings)
2 changes: 0 additions & 2 deletions src/v8_typed_array.h
Expand Up @@ -28,8 +28,6 @@ namespace v8_typed_array {

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

int SizeOfArrayElementForType(v8::ExternalArrayType type);

} // namespace v8_typed_array

#endif // V8_TYPED_ARRAY_H_

0 comments on commit 1444801

Please sign in to comment.