Remove some code duplication.
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2013 22:23:11 +0000 (22:23 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2013 22:23:11 +0000 (22:23 +0000)
Rubber stamped by Mark Hahnenberg.

* runtime/JSDataViewPrototype.cpp:
(JSC::getData):
(JSC::setData):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154143 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSDataViewPrototype.cpp

index 11220f1..8c84c68 100644 (file)
@@ -1,3 +1,13 @@
+2013-08-15  Filip Pizlo  <fpizlo@apple.com>
+
+        Remove some code duplication.
+        
+        Rubber stamped by Mark Hahnenberg.
+
+        * runtime/JSDataViewPrototype.cpp:
+        (JSC::getData):
+        (JSC::setData):
+
 2013-08-15  Julien Brianceau  <jbrianceau@nds.com>
 
         [DFG] isDouble() and isNumerical() should return true with KnownNumberUse UseKind.
index 4c755d7..c86606f 100644 (file)
@@ -122,7 +122,7 @@ EncodedJSValue getData(ExecState* exec)
     }
     
     unsigned byteLength = dataView->length();
-    if (elementSize > byteLength || byteOffset > byteLength - sizeof(typename Adaptor::Type))
+    if (elementSize > byteLength || byteOffset > byteLength - elementSize)
         return throwVMError(exec, createRangeError(exec, "Out of bounds access"));
     
     typename Adaptor::Type value = *reinterpret_cast<typename Adaptor::Type*>(static_cast<uint8_t*>(dataView->vector()) + byteOffset);
@@ -160,7 +160,7 @@ EncodedJSValue setData(ExecState* exec)
     }
     
     unsigned byteLength = dataView->length();
-    if (elementSize > byteLength || byteOffset > byteLength - sizeof(typename Adaptor::Type))
+    if (elementSize > byteLength || byteOffset > byteLength - elementSize)
         return throwVMError(exec, createRangeError(exec, "Out of bounds access"));
     
     if (needToFlipBytesIfLittleEndian(littleEndian))