From 4bf67b30bc85a6eda762bcdcd145b5b867c037a4 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Mon, 28 Sep 2015 17:58:23 -0700 Subject: [PATCH] Use std::min() for consistency inside ArraySplice --- src/RJSArray.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/RJSArray.cpp b/src/RJSArray.cpp index c66c4333..7d74e598 100644 --- a/src/RJSArray.cpp +++ b/src/RJSArray.cpp @@ -173,9 +173,7 @@ JSValueRef ArraySplice(JSContextRef ctx, JSObjectRef function, JSObjectRef thisO } long remove = std::max(RJSValidatedValueToNumber(ctx, arguments[1]), 0); - if (index + remove > size) { - remove = size - index; - } + remove = std::min(remove, size - index); std::vector removedObjects(remove); for (size_t i = 0; i < remove; i++) {