--- a/dom/bindings/WebIDLGlobalNameHash.cpp
+++ b/dom/bindings/WebIDLGlobalNameHash.cpp
@@ -6,16 +6,17 @@
#include "WebIDLGlobalNameHash.h"
#include "js/Class.h"
#include "js/GCAPI.h"
#include "js/Id.h"
#include "js/Wrapper.h"
#include "jsapi.h"
#include "jsfriendapi.h"
+#include "mozilla/ArrayUtils.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/HashFunctions.h"
#include "mozilla/Maybe.h"
#include "mozilla/dom/DOMJSClass.h"
#include "mozilla/dom/DOMJSProxyHandler.h"
#include "mozilla/dom/JSSlots.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/RegisterBindings.h"
@@ -87,17 +88,17 @@ struct WebIDLNameTableEntry : public PLD
{
if (mNameLength != aKey->mLength) {
return false;
}
const char* name = WebIDLGlobalNameHash::sNames + mNameOffset;
if (aKey->mLatin1String) {
- return PodEqual(aKey->mLatin1String, name, aKey->mLength);
+ return ArrayEqual(aKey->mLatin1String, name, aKey->mLength);
}
return nsCharTraits<char16_t>::compareASCII(aKey->mTwoBytesString, name,
aKey->mLength) == 0;
}
static KeyTypePointer KeyToPointer(KeyType aKey)
{
--- a/gfx/layers/LayerTreeInvalidation.cpp
+++ b/gfx/layers/LayerTreeInvalidation.cpp
@@ -8,16 +8,17 @@
#include <stdint.h> // for uint32_t
#include "ImageContainer.h" // for ImageContainer
#include "ImageLayers.h" // for ImageLayer, etc
#include "Layers.h" // for Layer, ContainerLayer, etc
#include "Units.h" // for ParentLayerIntRect
#include "gfxRect.h" // for gfxRect
#include "gfxUtils.h" // for gfxUtils
+#include "mozilla/ArrayUtils.h" // for ArrayEqual
#include "mozilla/gfx/BaseSize.h" // for BaseSize
#include "mozilla/gfx/Point.h" // for IntSize
#include "mozilla/mozalloc.h" // for operator new, etc
#include "nsDataHashtable.h" // for nsDataHashtable
#include "nsDebug.h" // for NS_ASSERTION
#include "nsHashKeys.h" // for nsPtrHashKey
#include "nsISupportsImpl.h" // for Layer::AddRef, etc
#include "nsRect.h" // for IntRect
@@ -628,19 +629,19 @@ public:
if (!border->GetLocalVisibleRegion().ToUnknownRegion().IsEqual(mVisibleRegion)) {
IntRect result = NewTransformedBoundsForLeaf();
result = result.Union(OldTransformedBoundsForLeaf());
aOutRegion = result;
return true;
}
- if (!PodEqual(&mColors[0], &border->GetColors()[0], 4) ||
- !PodEqual(&mWidths[0], &border->GetWidths()[0], 4) ||
- !PodEqual(&mCorners[0], &border->GetCorners()[0], 4) ||
+ if (!ArrayEqual(&mColors[0], &border->GetColors()[0], 4) ||
+ !ArrayEqual(&mWidths[0], &border->GetWidths()[0], 4) ||
+ !ArrayEqual(&mCorners[0], &border->GetCorners()[0], 4) ||
!mRect.IsEqualEdges(border->GetRect())) {
LTI_DUMP(NewTransformedBoundsForLeaf(), "bounds");
aOutRegion = NewTransformedBoundsForLeaf();
return true;
}
return true;
}
--- a/gfx/src/FilterSupport.cpp
+++ b/gfx/src/FilterSupport.cpp
@@ -4,16 +4,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "FilterSupport.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Filters.h"
#include "mozilla/gfx/Logging.h"
+#include "mozilla/ArrayUtils.h"
#include "mozilla/PodOperations.h"
#include "gfxContext.h"
#include "gfxPattern.h"
#include "gfxPlatform.h"
#include "gfx2DGlue.h"
#include "nsMargin.h"
@@ -758,17 +759,17 @@ FilterNodeFromPrimitiveDescription(const
}
case PrimitiveType::ColorMatrix:
{
float colorMatrix[20];
uint32_t type = atts.GetUint(eColorMatrixType);
const nsTArray<float>& values = atts.GetFloats(eColorMatrixValues);
if (NS_FAILED(ComputeColorMatrix(type, values, colorMatrix)) ||
- PodEqual(colorMatrix, identityMatrix)) {
+ ArrayEqual(colorMatrix, identityMatrix)) {
RefPtr<FilterNode> filter(aSources[0]);
return filter.forget();
}
Matrix5x4 matrix(colorMatrix[0], colorMatrix[5], colorMatrix[10], colorMatrix[15],
colorMatrix[1], colorMatrix[6], colorMatrix[11], colorMatrix[16],
colorMatrix[2], colorMatrix[7], colorMatrix[12], colorMatrix[17],
colorMatrix[3], colorMatrix[8], colorMatrix[13], colorMatrix[18],
colorMatrix[4], colorMatrix[9], colorMatrix[14], colorMatrix[19]);
@@ -958,17 +959,17 @@ FilterNodeFromPrimitiveDescription(const
uint32_t op = atts.GetUint(eCompositeOperator);
if (op == SVG_FECOMPOSITE_OPERATOR_ARITHMETIC) {
const nsTArray<float>& coefficients = atts.GetFloats(eCompositeCoefficients);
static const float allZero[4] = { 0, 0, 0, 0 };
filter = aDT->CreateFilter(FilterType::ARITHMETIC_COMBINE);
// All-zero coefficients sometimes occur in junk filters.
if (!filter ||
(coefficients.Length() == ArrayLength(allZero) &&
- PodEqual(coefficients.Elements(), allZero, ArrayLength(allZero)))) {
+ ArrayEqual(coefficients.Elements(), allZero, ArrayLength(allZero)))) {
return nullptr;
}
filter->SetAttribute(ATT_ARITHMETIC_COMBINE_COEFFICIENTS,
coefficients.Elements(), coefficients.Length());
filter->SetInput(IN_ARITHMETIC_COMBINE_IN, aSources[0]);
filter->SetInput(IN_ARITHMETIC_COMBINE_IN2, aSources[1]);
} else {
filter = aDT->CreateFilter(FilterType::COMPOSITE);
--- a/gfx/tests/gtest/TestSwizzle.cpp
+++ b/gfx/tests/gtest/TestSwizzle.cpp
@@ -1,17 +1,17 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "gtest/gtest.h"
+#include "mozilla/ArrayUtils.h"
#include "mozilla/gfx/Swizzle.h"
-#include "mozilla/PodOperations.h"
using namespace mozilla;
using namespace mozilla::gfx;
TEST(Moz2D, PremultiplyData) {
const uint8_t in_bgra[5*4] =
{
255, 255, 0, 255, // verify 255 alpha leaves RGB unchanged
@@ -45,27 +45,27 @@ TEST(Moz2D, PremultiplyData) {
0, 0, 0, 0,
0, 0, 0, 0,
128, 0, 0, 128,
};
PremultiplyData(in_bgra, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
out, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
IntSize(5, 1));
- EXPECT_TRUE(PodEqual(out, check_bgra));
+ EXPECT_TRUE(ArrayEqual(out, check_bgra));
PremultiplyData(in_bgra, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
out, sizeof(in_bgra), SurfaceFormat::R8G8B8A8,
IntSize(5, 1));
- EXPECT_TRUE(PodEqual(out, check_rgba));
+ EXPECT_TRUE(ArrayEqual(out, check_rgba));
PremultiplyData(in_bgra, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
out, sizeof(in_bgra), SurfaceFormat::A8R8G8B8,
IntSize(5, 1));
- EXPECT_TRUE(PodEqual(out, check_argb));
+ EXPECT_TRUE(ArrayEqual(out, check_argb));
}
TEST(Moz2D, UnpremultiplyData) {
const uint8_t in_bgra[5*4] =
{
255, 255, 0, 255, // verify 255 alpha leaves RGB unchanged
0, 0, 255, 255,
0, 0, 0, 0, // verify 0 alpha leaves RGB at 0
@@ -98,27 +98,27 @@ TEST(Moz2D, UnpremultiplyData) {
0, 0, 0, 0,
64, 0, 0, 0,
128, 0, 0, 255,
};
UnpremultiplyData(in_bgra, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
out, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
IntSize(5, 1));
- EXPECT_TRUE(PodEqual(out, check_bgra));
+ EXPECT_TRUE(ArrayEqual(out, check_bgra));
UnpremultiplyData(in_bgra, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
out, sizeof(in_bgra), SurfaceFormat::R8G8B8A8,
IntSize(5, 1));
- EXPECT_TRUE(PodEqual(out, check_rgba));
+ EXPECT_TRUE(ArrayEqual(out, check_rgba));
UnpremultiplyData(in_bgra, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
out, sizeof(in_bgra), SurfaceFormat::A8R8G8B8,
IntSize(5, 1));
- EXPECT_TRUE(PodEqual(out, check_argb));
+ EXPECT_TRUE(ArrayEqual(out, check_argb));
}
TEST(Moz2D, SwizzleData) {
const uint8_t in_bgra[5*4] =
{
253, 254, 0, 255,
0, 0, 255, 255,
0, 0, 0, 0,
@@ -194,47 +194,47 @@ TEST(Moz2D, SwizzleData) {
PACK_RGB565(0, 0, 0),
PACK_RGB565(1, 2, 3),
PACK_RGB565(127, 0, 9),
};
SwizzleData(in_bgra, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
out, sizeof(out), SurfaceFormat::B8G8R8A8,
IntSize(5, 1));
- EXPECT_TRUE(PodEqual(out, check_bgra));
+ EXPECT_TRUE(ArrayEqual(out, check_bgra));
SwizzleData(in_bgra, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
out, sizeof(out), SurfaceFormat::R8G8B8A8,
IntSize(5, 1));
- EXPECT_TRUE(PodEqual(out, check_rgba));
+ EXPECT_TRUE(ArrayEqual(out, check_rgba));
SwizzleData(in_bgra, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
out, sizeof(out), SurfaceFormat::A8R8G8B8,
IntSize(5, 1));
- EXPECT_TRUE(PodEqual(out, check_argb));
+ EXPECT_TRUE(ArrayEqual(out, check_argb));
SwizzleData(in_bgra, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
out, sizeof(out), SurfaceFormat::R8G8B8X8,
IntSize(5, 1));
- EXPECT_TRUE(PodEqual(out, check_rgbx));
+ EXPECT_TRUE(ArrayEqual(out, check_rgbx));
SwizzleData(in_bgra, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
out24, sizeof(out24), SurfaceFormat::B8G8R8,
IntSize(5, 1));
- EXPECT_TRUE(PodEqual(out24, check_bgr));
+ EXPECT_TRUE(ArrayEqual(out24, check_bgr));
SwizzleData(in_bgra, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
out24, sizeof(out24), SurfaceFormat::R8G8B8,
IntSize(5, 1));
- EXPECT_TRUE(PodEqual(out24, check_rgb));
+ EXPECT_TRUE(ArrayEqual(out24, check_rgb));
SwizzleData(in_bgra, sizeof(in_bgra), SurfaceFormat::B8G8R8A8,
out8, sizeof(out8), SurfaceFormat::A8,
IntSize(5, 1));
- EXPECT_TRUE(PodEqual(out8, check_a));
+ EXPECT_TRUE(ArrayEqual(out8, check_a));
SwizzleData(SurfaceFormat::A8R8G8B8_UINT32 == SurfaceFormat::A8R8G8B8 ? check_argb : check_bgra,
sizeof(in_bgra), SurfaceFormat::A8R8G8B8_UINT32,
reinterpret_cast<uint8_t*>(out16), sizeof(out16), SurfaceFormat::R5G6B5_UINT16,
IntSize(5, 1));
- EXPECT_TRUE(PodEqual(out16, check_16));
+ EXPECT_TRUE(ArrayEqual(out16, check_16));
}
--- a/js/src/jit/CacheIRCompiler.cpp
+++ b/js/src/jit/CacheIRCompiler.cpp
@@ -1,16 +1,18 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "jit/CacheIRCompiler.h"
+#include "mozilla/ArrayUtils.h"
+
#include <utility>
#include "jit/IonIC.h"
#include "jit/SharedICHelpers.h"
#include "builtin/Boolean-inl.h"
#include "jit/MacroAssembler-inl.h"
@@ -1092,17 +1094,17 @@ CacheIRStubKey::match(const CacheIRStubK
return false;
if (entry.stubInfo->engine() != l.engine)
return false;
if (entry.stubInfo->codeLength() != l.length)
return false;
- if (!mozilla::PodEqual(entry.stubInfo->code(), l.code, l.length))
+ if (!mozilla::ArrayEqual(entry.stubInfo->code(), l.code, l.length))
return false;
return true;
}
CacheIRReader::CacheIRReader(const CacheIRStubInfo* stubInfo)
: CacheIRReader(stubInfo->code(), stubInfo->code() + stubInfo->codeLength())
{}
--- a/js/src/jsapi-tests/testExternalStrings.cpp
+++ b/js/src/jsapi-tests/testExternalStrings.cpp
@@ -1,19 +1,18 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ArrayUtils.h"
-#include "mozilla/PodOperations.h"
#include "jsapi-tests/tests.h"
+using mozilla::ArrayEqual;
using mozilla::ArrayLength;
-using mozilla::PodEqual;
static const char16_t arr[] = {
'h', 'i', ',', 'd', 'o', 'n', '\'', 't', ' ', 'd', 'e', 'l', 'e', 't', 'e', ' ', 'm', 'e', '\0'
};
static const size_t arrlen = ArrayLength(arr) - 1;
static int finalized1 = 0;
static int finalized2 = 0;
@@ -22,17 +21,17 @@ static void
finalize_str(const JSStringFinalizer* fin, char16_t* chars);
static const JSStringFinalizer finalizer1 = { finalize_str };
static const JSStringFinalizer finalizer2 = { finalize_str };
static void
finalize_str(const JSStringFinalizer* fin, char16_t* chars)
{
- if (chars && PodEqual(const_cast<const char16_t*>(chars), arr, arrlen)) {
+ if (chars && ArrayEqual(const_cast<const char16_t*>(chars), arr, arrlen)) {
if (fin == &finalizer1) {
++finalized1;
} else if (fin == &finalizer2) {
++finalized2;
}
}
}
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -122,24 +122,23 @@
#include "vm/Stack-inl.h"
using namespace js;
using namespace js::cli;
using namespace js::shell;
using js::shell::RCFile;
+using mozilla::ArrayEqual;
using mozilla::ArrayLength;
using mozilla::Atomic;
using mozilla::MakeScopeExit;
using mozilla::Maybe;
using mozilla::Nothing;
using mozilla::NumberEqualsInt32;
-using mozilla::PodCopy;
-using mozilla::PodEqual;
using mozilla::TimeDuration;
using mozilla::TimeStamp;
// Avoid an unnecessary NSPR dependency on Linux and OS X just for the shell.
#ifdef JS_POSIX_NSPR
enum PRLibSpecType { PR_LibSpec_Pathname };
@@ -2067,17 +2066,17 @@ Evaluate(JSContext* cx, unsigned argc, V
char saveLengthStr[16];
SprintfLiteral(saveLengthStr,"%zu", saveBuffer.length());
JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_CACHE_EQ_SIZE_FAILED,
loadLengthStr, saveLengthStr);
return false;
}
- if (!PodEqual(loadBuffer.begin(), saveBuffer.begin(), loadBuffer.length())) {
+ if (!ArrayEqual(loadBuffer.begin(), saveBuffer.begin(), loadBuffer.length())) {
JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr,
JSSMSG_CACHE_EQ_CONTENT_FAILED);
return false;
}
}
size_t saveLength = saveBuffer.length();
if (saveLength >= INT32_MAX) {
@@ -5556,17 +5555,17 @@ SingleStepCallback(void* arg, jit::Simul
}
}
ShellContext* sc = GetShellContext(cx);
// Only append the stack if it differs from the last stack.
if (sc->stacks.empty() ||
sc->stacks.back().length() != stack.length() ||
- !PodEqual(sc->stacks.back().begin(), stack.begin(), stack.length()))
+ !ArrayEqual(sc->stacks.back().begin(), stack.begin(), stack.length()))
{
if (!sc->stacks.append(std::move(stack)))
oomUnsafe.crash("stacks.append");
}
}
#endif
static bool
--- a/js/src/util/Text.h
+++ b/js/src/util/Text.h
@@ -2,16 +2,17 @@
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef util_Text_h
#define util_Text_h
+#include "mozilla/ArrayUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/TextUtils.h"
#include <ctype.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
@@ -57,17 +58,17 @@ class StringBuffer;
template <typename Char1, typename Char2>
inline bool
EqualChars(const Char1* s1, const Char2* s2, size_t len);
template <typename Char1>
inline bool
EqualChars(const Char1* s1, const Char1* s2, size_t len)
{
- return mozilla::PodEqual(s1, s2, len);
+ return mozilla::ArrayEqual(s1, s2, len);
}
template <typename Char1, typename Char2>
inline bool
EqualChars(const Char1* s1, const Char2* s2, size_t len)
{
for (const Char1* s1end = s1 + len; s1 < s1end; s1++, s2++) {
if (*s1 != *s2)
--- a/js/src/vm/Iteration.cpp
+++ b/js/src/vm/Iteration.cpp
@@ -3,16 +3,17 @@
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* JavaScript iterators. */
#include "vm/Iteration.h"
+#include "mozilla/ArrayUtils.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Likely.h"
#include "mozilla/Maybe.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/PodOperations.h"
#include "mozilla/Unused.h"
#include <algorithm>
@@ -42,20 +43,20 @@
#include "vm/NativeObject-inl.h"
#include "vm/ReceiverGuard-inl.h"
#include "vm/Stack-inl.h"
#include "vm/StringType-inl.h"
using namespace js;
using namespace js::gc;
+using mozilla::ArrayEqual;
using mozilla::DebugOnly;
using mozilla::Maybe;
using mozilla::PodCopy;
-using mozilla::PodEqual;
typedef Rooted<PropertyIteratorObject*> RootedPropertyIteratorObject;
static const gc::AllocKind ITERATOR_FINALIZE_KIND = gc::AllocKind::OBJECT2_BACKGROUND;
void
NativeIterator::trace(JSTracer* trc)
{
@@ -773,18 +774,18 @@ js::NewEmptyPropertyIterator(JSContext*
/* static */ bool
IteratorHashPolicy::match(PropertyIteratorObject* obj, const Lookup& lookup)
{
NativeIterator* ni = obj->getNativeIterator();
if (ni->guardKey() != lookup.key || ni->guardCount() != lookup.numGuards)
return false;
- return PodEqual(reinterpret_cast<ReceiverGuard*>(ni->guardsBegin()), lookup.guards,
- ni->guardCount());
+ return ArrayEqual(reinterpret_cast<ReceiverGuard*>(ni->guardsBegin()), lookup.guards,
+ ni->guardCount());
}
static inline bool
CanCompareIterableObjectToCache(JSObject* obj)
{
if (obj->isNative())
return obj->as<NativeObject>().hasEmptyElements();
if (obj->is<UnboxedPlainObject>()) {
--- a/js/src/vm/JSAtom.cpp
+++ b/js/src/vm/JSAtom.cpp
@@ -91,24 +91,24 @@ js::AtomHasher::match(const AtomStateEnt
if (lookup.atom)
return lookup.atom == key;
if (key->length() != lookup.length || key->hash() != lookup.hash)
return false;
if (key->hasLatin1Chars()) {
const Latin1Char* keyChars = key->latin1Chars(lookup.nogc);
if (lookup.isLatin1)
- return mozilla::PodEqual(keyChars, lookup.latin1Chars, lookup.length);
+ return mozilla::ArrayEqual(keyChars, lookup.latin1Chars, lookup.length);
return EqualChars(keyChars, lookup.twoByteChars, lookup.length);
}
const char16_t* keyChars = key->twoByteChars(lookup.nogc);
if (lookup.isLatin1)
return EqualChars(lookup.latin1Chars, keyChars, lookup.length);
- return mozilla::PodEqual(keyChars, lookup.twoByteChars, lookup.length);
+ return mozilla::ArrayEqual(keyChars, lookup.twoByteChars, lookup.length);
}
inline JSAtom*
js::AtomStateEntry::asPtr(JSContext* cx) const
{
JSAtom* atom = asPtrUnbarriered();
if (!cx->helperThread())
JSString::readBarrier(atom);
--- a/js/src/vm/JSScript.h
+++ b/js/src/vm/JSScript.h
@@ -4,20 +4,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* JS script descriptor. */
#ifndef vm_JSScript_h
#define vm_JSScript_h
+#include "mozilla/ArrayUtils.h"
#include "mozilla/Atomics.h"
#include "mozilla/Maybe.h"
#include "mozilla/MemoryReporting.h"
-#include "mozilla/PodOperations.h"
#include "mozilla/Variant.h"
#include "jstypes.h"
#include "frontend/NameAnalysisTypes.h"
#include "gc/Barrier.h"
#include "gc/Rooting.h"
#include "jit/IonCode.h"
@@ -878,17 +878,17 @@ struct ScriptBytecodeHasher
static bool match(SharedScriptData* entry, const Lookup& lookup) {
const SharedScriptData* data = lookup.scriptData;
if (entry->natoms() != data->natoms())
return false;
if (entry->codeLength() != data->codeLength())
return false;
if (entry->numNotes() != data->numNotes())
return false;
- return mozilla::PodEqual<uint8_t>(entry->data(), data->data(), data->dataLength());
+ return mozilla::ArrayEqual<uint8_t>(entry->data(), data->data(), data->dataLength());
}
};
class AutoLockScriptData;
using ScriptDataTable = HashSet<SharedScriptData*,
ScriptBytecodeHasher,
SystemAllocPolicy>;
--- a/js/src/vm/StringType.cpp
+++ b/js/src/vm/StringType.cpp
@@ -1,16 +1,17 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "vm/StringType-inl.h"
+#include "mozilla/ArrayUtils.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/HashFunctions.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/PodOperations.h"
#include "mozilla/RangedPtr.h"
#include "mozilla/TextUtils.h"
#include "mozilla/TypeTraits.h"
@@ -25,21 +26,21 @@
#include "vm/GeckoProfiler-inl.h"
#include "vm/JSContext-inl.h"
#include "vm/JSObject-inl.h"
#include "vm/Realm-inl.h"
using namespace js;
+using mozilla::ArrayEqual;
using mozilla::IsAsciiDigit;
using mozilla::IsNegativeZero;
using mozilla::IsSame;
using mozilla::PodCopy;
-using mozilla::PodEqual;
using mozilla::RangedPtr;
using mozilla::RoundUpPow2;
using mozilla::Unused;
using JS::AutoCheckCannotGC;
using UniqueLatin1Chars = UniquePtr<Latin1Char[], JS::FreePolicy>;
@@ -841,46 +842,46 @@ js::EqualChars(JSLinearString* str1, JSL
{
MOZ_ASSERT(str1->length() == str2->length());
size_t len = str1->length();
AutoCheckCannotGC nogc;
if (str1->hasTwoByteChars()) {
if (str2->hasTwoByteChars())
- return PodEqual(str1->twoByteChars(nogc), str2->twoByteChars(nogc), len);
+ return ArrayEqual(str1->twoByteChars(nogc), str2->twoByteChars(nogc), len);
return EqualChars(str2->latin1Chars(nogc), str1->twoByteChars(nogc), len);
}
if (str2->hasLatin1Chars())
- return PodEqual(str1->latin1Chars(nogc), str2->latin1Chars(nogc), len);
+ return ArrayEqual(str1->latin1Chars(nogc), str2->latin1Chars(nogc), len);
return EqualChars(str1->latin1Chars(nogc), str2->twoByteChars(nogc), len);
}
bool
js::HasSubstringAt(JSLinearString* text, JSLinearString* pat, size_t start)
{
MOZ_ASSERT(start + pat->length() <= text->length());
size_t patLen = pat->length();
AutoCheckCannotGC nogc;
if (text->hasLatin1Chars()) {
const Latin1Char* textChars = text->latin1Chars(nogc) + start;
if (pat->hasLatin1Chars())
- return PodEqual(textChars, pat->latin1Chars(nogc), patLen);
+ return ArrayEqual(textChars, pat->latin1Chars(nogc), patLen);
return EqualChars(textChars, pat->twoByteChars(nogc), patLen);
}
const char16_t* textChars = text->twoByteChars(nogc) + start;
if (pat->hasTwoByteChars())
- return PodEqual(textChars, pat->twoByteChars(nogc), patLen);
+ return ArrayEqual(textChars, pat->twoByteChars(nogc), patLen);
return EqualChars(pat->latin1Chars(nogc), textChars, patLen);
}
bool
js::EqualStrings(JSContext* cx, JSString* str1, JSString* str2, bool* result)
{
if (str1 == str2) {
@@ -986,17 +987,17 @@ js::StringEqualsAscii(JSLinearString* st
#endif
if (length != str->length())
return false;
const Latin1Char* latin1 = reinterpret_cast<const Latin1Char*>(asciiBytes);
AutoCheckCannotGC nogc;
return str->hasLatin1Chars()
- ? PodEqual(latin1, str->latin1Chars(nogc), length)
+ ? ArrayEqual(latin1, str->latin1Chars(nogc), length)
: EqualChars(latin1, str->twoByteChars(nogc), length);
}
template <typename CharT>
/* static */ bool
JSFlatString::isIndexSlow(const CharT* s, size_t length, uint32_t* indexp)
{
CharT ch = *s;
@@ -1753,17 +1754,17 @@ ExternalStringCache::lookup(const char16
// The cache is purged on GC so any string we get from the cache
// must have been allocated after the GC started.
return str;
}
// Compare the chars. Don't do this for long strings as it will be
// faster to allocate a new external string.
static const size_t MaxLengthForCharComparison = 100;
- if (len <= MaxLengthForCharComparison && PodEqual(chars, strChars, len))
+ if (len <= MaxLengthForCharComparison && ArrayEqual(chars, strChars, len))
return str;
}
return nullptr;
}
MOZ_ALWAYS_INLINE void
ExternalStringCache::put(JSString* str)
--- a/js/src/vm/Xdr.cpp
+++ b/js/src/vm/Xdr.cpp
@@ -1,32 +1,33 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "vm/Xdr.h"
+#include "mozilla/ArrayUtils.h"
#include "mozilla/PodOperations.h"
#include "mozilla/ScopeExit.h"
#include <string.h>
#include "jsapi.h"
#include "jsutil.h"
#include "vm/Debugger.h"
#include "vm/EnvironmentObject.h"
#include "vm/JSContext.h"
#include "vm/JSScript.h"
#include "vm/TraceLogging.h"
using namespace js;
-using mozilla::PodEqual;
+using mozilla::ArrayEqual;
template<XDRMode mode>
LifoAlloc&
XDRState<mode>::lifoAlloc() const {
return buf.cx()->tempLifoAlloc();
}
#ifdef DEBUG
@@ -111,17 +112,17 @@ VersionCheck(XDRState<mode>* xdr)
if (!decodedBuildId.resize(buildIdLength)) {
ReportOutOfMemory(xdr->cx());
return xdr->fail(JS::TranscodeResult_Throw);
}
MOZ_TRY(xdr->codeBytes(decodedBuildId.begin(), buildIdLength));
// We do not provide binary compatibility with older scripts.
- if (!PodEqual(decodedBuildId.begin(), buildId.begin(), buildIdLength))
+ if (!ArrayEqual(decodedBuildId.begin(), buildId.begin(), buildIdLength))
return xdr->fail(JS::TranscodeResult_Failure_BadBuildId);
}
return Ok();
}
template<XDRMode mode>
XDRResult
--- a/js/src/wasm/AsmJS.cpp
+++ b/js/src/wasm/AsmJS.cpp
@@ -13,16 +13,17 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "wasm/AsmJS.h"
+#include "mozilla/ArrayUtils.h"
#include "mozilla/Attributes.h"
#include "mozilla/Compression.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/Unused.h"
#include <new>
#include "jsmath.h"
@@ -54,24 +55,24 @@
#include "vm/ArrayBufferObject-inl.h"
#include "vm/JSObject-inl.h"
using namespace js;
using namespace js::frontend;
using namespace js::jit;
using namespace js::wasm;
+using mozilla::ArrayEqual;
using mozilla::CeilingLog2;
using mozilla::Compression::LZ4;
using mozilla::HashGeneric;
using mozilla::IsNaN;
using mozilla::IsNegativeZero;
using mozilla::IsPositiveZero;
using mozilla::IsPowerOfTwo;
-using mozilla::PodEqual;
using mozilla::PodZero;
using mozilla::PositiveInfinity;
using mozilla::Unused;
using JS::AsmJSOption;
using JS::GenericNaN;
/*****************************************************************************/
@@ -8549,17 +8550,17 @@ class ModuleCharsForLookup : ModuleChars
}
bool match(AsmJSParser& parser) const {
const char16_t* parseBegin = parser.tokenStream.codeUnitPtrAt(beginOffset(parser));
const char16_t* parseLimit = parser.tokenStream.rawLimit();
MOZ_ASSERT(parseLimit >= parseBegin);
if (uint32_t(parseLimit - parseBegin) < chars_.length())
return false;
- if (!PodEqual(chars_.begin(), parseBegin, chars_.length()))
+ if (!ArrayEqual(chars_.begin(), parseBegin, chars_.length()))
return false;
if (isFunCtor_ != parser.pc->isStandaloneFunctionBody())
return false;
if (isFunCtor_) {
// For function statements, the closing } is included as the last
// character of the matched source. For Function constructor,
// parsing terminates with EOF which we must explicitly check. This
// prevents
--- a/js/src/wasm/WasmTypes.cpp
+++ b/js/src/wasm/WasmTypes.cpp
@@ -566,17 +566,17 @@ Assumptions::clone(const Assumptions& ot
return buildId.appendAll(other.buildId);
}
bool
Assumptions::operator==(const Assumptions& rhs) const
{
return cpuId == rhs.cpuId &&
buildId.length() == rhs.buildId.length() &&
- PodEqual(buildId.begin(), rhs.buildId.begin(), buildId.length());
+ ArrayEqual(buildId.begin(), rhs.buildId.begin(), buildId.length());
}
size_t
Assumptions::serializedSize() const
{
return sizeof(uint32_t) +
SerializedPodVectorSize(buildId);
}
--- a/js/src/wasm/WasmTypes.h
+++ b/js/src/wasm/WasmTypes.h
@@ -15,16 +15,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef wasm_types_h
#define wasm_types_h
#include "mozilla/Alignment.h"
+#include "mozilla/ArrayUtils.h"
#include "mozilla/Atomics.h"
#include "mozilla/EnumeratedArray.h"
#include "mozilla/HashFunctions.h"
#include "mozilla/Maybe.h"
#include "mozilla/RefPtr.h"
#include "mozilla/Unused.h"
#include "NamespaceImports.h"
@@ -70,25 +71,25 @@ typedef Handle<WasmTableObject*> HandleW
typedef MutableHandle<WasmTableObject*> MutableHandleWasmTableObject;
class WasmGlobalObject;
typedef GCVector<WasmGlobalObject*, 0, SystemAllocPolicy> WasmGlobalObjectVector;
typedef Rooted<WasmGlobalObject*> RootedWasmGlobalObject;
namespace wasm {
+using mozilla::ArrayEqual;
using mozilla::Atomic;
using mozilla::DebugOnly;
using mozilla::EnumeratedArray;
using mozilla::Maybe;
using mozilla::MallocSizeOf;
using mozilla::Nothing;
using mozilla::PodZero;
using mozilla::PodCopy;
-using mozilla::PodEqual;
using mozilla::Some;
using mozilla::Unused;
typedef int8_t I8x16[16];
typedef int16_t I16x8[8];
typedef int32_t I32x4[4];
typedef float F32x4[4];
--- a/layout/style/nsCSSPropertyIDSet.h
+++ b/layout/style/nsCSSPropertyIDSet.h
@@ -3,17 +3,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* bit vectors for sets of CSS properties */
#ifndef nsCSSPropertyIDSet_h__
#define nsCSSPropertyIDSet_h__
#include "mozilla/ArrayUtils.h"
-#include "mozilla/PodOperations.h"
#include "nsCSSPropertyID.h"
#include <limits.h> // for CHAR_BIT
/**
* nsCSSPropertyIDSet maintains a set of non-shorthand CSS properties. In
* other words, for each longhand CSS property we support, it has a bit
* for whether that property is in the set.
@@ -59,17 +58,17 @@ public:
void AssertIsEmpty(const char* aText) const {
for (size_t i = 0; i < mozilla::ArrayLength(mProperties); ++i) {
NS_ASSERTION(mProperties[i] == 0, aText);
}
}
bool Equals(const nsCSSPropertyIDSet& aOther) const {
- return mozilla::PodEqual(mProperties, aOther.mProperties);
+ return mozilla::ArrayEqual(mProperties, aOther.mProperties);
}
bool IsEmpty() const {
for (size_t i = 0; i < mozilla::ArrayLength(mProperties); ++i) {
if (mProperties[i] != 0) {
return false;
}
}
--- a/mfbt/ArrayUtils.h
+++ b/mfbt/ArrayUtils.h
@@ -9,16 +9,17 @@
*/
#ifndef mozilla_ArrayUtils_h
#define mozilla_ArrayUtils_h
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
+#include <algorithm>
#include <stddef.h>
#ifdef __cplusplus
#include "mozilla/Alignment.h"
#include "mozilla/Array.h"
#include "mozilla/EnumeratedArray.h"
#include "mozilla/TypeTraits.h"
@@ -93,16 +94,34 @@ ArrayEnd(Array<T, N>& aArr)
template<typename T, size_t N>
constexpr const T*
ArrayEnd(const Array<T, N>& aArr)
{
return &aArr[0] + ArrayLength(aArr);
}
+/**
+ * std::equal has subpar ergonomics.
+ */
+
+template<typename T, typename U, size_t N>
+bool
+ArrayEqual(const T (&a)[N], const U (&b)[N])
+{
+ return std::equal(a, a + N, b);
+}
+
+template<typename T, typename U>
+bool
+ArrayEqual(const T* const a, const U* const b, const size_t n)
+{
+ return std::equal(a, a + n, b);
+}
+
namespace detail {
template<typename AlignType, typename Pointee,
typename = EnableIf<!IsVoid<AlignType>::value>>
struct AlignedChecker
{
static void
test(const Pointee* aPtr)
--- a/mfbt/PodOperations.h
+++ b/mfbt/PodOperations.h
@@ -14,16 +14,17 @@
#ifndef mozilla_PodOperations_h
#define mozilla_PodOperations_h
#include "mozilla/Array.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Attributes.h"
+#include <algorithm>
#include <stdint.h>
#include <string.h>
namespace mozilla {
/** Set the contents of |aT| to 0. */
template<typename T>
static MOZ_ALWAYS_INLINE void
@@ -153,44 +154,15 @@ static MOZ_ALWAYS_INLINE void
PodMove(T* aDst, const T* aSrc, size_t aNElem)
{
MOZ_ASSERT(aNElem <= SIZE_MAX / sizeof(T),
"trying to move an impossible number of elements");
memmove(aDst, aSrc, aNElem * sizeof(T));
}
/**
- * Determine whether the |len| elements at |one| are memory-identical to the
- * |len| elements at |two|.
+ * Looking for a PodEqual? Use ArrayEqual from ArrayUtils.h.
+ * Note that we *cannot* use memcmp for this, due to padding bytes, etc..
*/
-template<typename T>
-static MOZ_ALWAYS_INLINE bool
-PodEqual(const T* one, const T* two, size_t len)
-{
- if (len < 128) {
- const T* p1end = one + len;
- const T* p1 = one;
- const T* p2 = two;
- for (; p1 < p1end; p1++, p2++) {
- if (*p1 != *p2) {
- return false;
- }
- }
- return true;
- }
-
- return !memcmp(one, two, len * sizeof(T));
-}
-
-/*
- * Determine whether the |N| elements at |one| are memory-identical to the
- * |N| elements at |two|.
- */
-template <class T, size_t N>
-static MOZ_ALWAYS_INLINE bool
-PodEqual(const T (&one)[N], const T (&two)[N])
-{
- return PodEqual(one, two, N);
-}
} // namespace mozilla
#endif /* mozilla_PodOperations_h */
--- a/security/certverifier/ExtendedValidation.cpp
+++ b/security/certverifier/ExtendedValidation.cpp
@@ -1097,27 +1097,27 @@ CertIsAuthoritativeForEVPolicy(const Uni
const SECOidData* cabforumOIDData = SECOID_FindOIDByTag(sCABForumEVOIDTag);
for (size_t i = 0; i < ArrayLength(kEVInfos); ++i) {
const EVInfo& entry = kEVInfos[i];
// This check ensures that only the specific roots we approve for EV get
// that status, and not certs (roots or otherwise) that happen to have an
// OID that's already been approved for EV.
- if (!PodEqual(fingerprint, entry.sha256Fingerprint)) {
+ if (!ArrayEqual(fingerprint, entry.sha256Fingerprint)) {
continue;
}
if (cabforumOIDData && cabforumOIDData->oid.len == policy.numBytes &&
- PodEqual(cabforumOIDData->oid.data, policy.bytes, policy.numBytes)) {
+ ArrayEqual(cabforumOIDData->oid.data, policy.bytes, policy.numBytes)) {
return true;
}
const SECOidData* oidData = SECOID_FindOIDByTag(sEVInfoOIDTags[i]);
if (oidData && oidData->oid.len == policy.numBytes &&
- PodEqual(oidData->oid.data, policy.bytes, policy.numBytes)) {
+ ArrayEqual(oidData->oid.data, policy.bytes, policy.numBytes)) {
return true;
}
}
return false;
}
nsresult
@@ -1183,17 +1183,17 @@ LoadExtendedValidationInfo()
} else {
unsigned char certFingerprint[SHA256_LENGTH];
srv = PK11_HashBuf(SEC_OID_SHA256, certFingerprint, cert->derCert.data,
AssertedCast<int32_t>(cert->derCert.len));
MOZ_ASSERT(srv == SECSuccess, "Could not hash EV root");
if (srv != SECSuccess) {
return NS_ERROR_FAILURE;
}
- bool same = PodEqual(certFingerprint, entry.sha256Fingerprint);
+ bool same = ArrayEqual(certFingerprint, entry.sha256Fingerprint);
MOZ_ASSERT(same, "EV root fingerprint mismatch");
if (!same) {
return NS_ERROR_FAILURE;
}
}
#endif
// This is the code that actually enables these roots for EV.
ScopedAutoSECItem evOIDItem;
--- a/security/certverifier/TrustOverrideUtils.h
+++ b/security/certverifier/TrustOverrideUtils.h
@@ -4,17 +4,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef TrustOverrides_h
#define TrustOverrides_h
#include "nsNSSCertificate.h"
#include "nsNSSCertValidity.h"
-#include "mozilla/PodOperations.h"
+#include "mozilla/ArrayUtils.h"
using namespace mozilla;
struct DataAndLength {
const uint8_t* data;
uint32_t len;
};
@@ -24,17 +24,17 @@ CertDNIsInList(const CERTCertificate* aC
{
MOZ_ASSERT(aCert);
if (!aCert) {
return false;
}
for (auto& dn: aDnList) {
if (aCert->derSubject.len == dn.len &&
- mozilla::PodEqual(aCert->derSubject.data, dn.data, dn.len)) {
+ mozilla::ArrayEqual(aCert->derSubject.data, dn.data, dn.len)) {
return true;
}
}
return false;
}
template<size_t T>
static bool
@@ -42,36 +42,36 @@ CertSPKIIsInList(const CERTCertificate*
{
MOZ_ASSERT(aCert);
if (!aCert) {
return false;
}
for (auto& spki: aSpkiList) {
if (aCert->derPublicKey.len == spki.len &&
- mozilla::PodEqual(aCert->derPublicKey.data, spki.data, spki.len)) {
+ mozilla::ArrayEqual(aCert->derPublicKey.data, spki.data, spki.len)) {
return true;
}
}
return false;
}
template<size_t T, size_t R>
static bool
CertMatchesStaticData(const CERTCertificate* cert,
const unsigned char (&subject)[T],
const unsigned char (&spki)[R]) {
MOZ_ASSERT(cert);
if (!cert) {
return false;
}
return cert->derSubject.len == T &&
- mozilla::PodEqual(cert->derSubject.data, subject, T) &&
+ mozilla::ArrayEqual(cert->derSubject.data, subject, T) &&
cert->derPublicKey.len == R &&
- mozilla::PodEqual(cert->derPublicKey.data, spki, R);
+ mozilla::ArrayEqual(cert->derPublicKey.data, spki, R);
}
// Implements the graduated Symantec distrust algorithm from Bug 1409257.
// This accepts a pre-segmented certificate chain (e.g. SegmentCertificateChain)
// as |intCerts| and |eeCert|, and pre-assumes that the root has been identified
// as being affected (this is to avoid duplicate Segment operations in the
// NSSCertDBTrustDomain). If |permitAfterDate| is non-zero, this algorithm
// returns "not distrusted" if the NotBefore date of |eeCert| is after
--- a/security/manager/ssl/tests/gtest/MD4Test.cpp
+++ b/security/manager/ssl/tests/gtest/MD4Test.cpp
@@ -3,18 +3,18 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// This file tests the md4.c implementation.
#include "gtest/gtest.h"
#include "md4.h"
+#include "mozilla/ArrayUtils.h"
#include "mozilla/Casting.h"
-#include "mozilla/PodOperations.h"
struct RFC1320TestParams
{
const char* data;
const uint8_t expectedHash[16];
};
static const RFC1320TestParams RFC1320_TEST_PARAMS[] =
@@ -63,14 +63,14 @@ class psm_MD4
};
TEST_P(psm_MD4, RFC1320TestValues)
{
const RFC1320TestParams& params(GetParam());
uint8_t actualHash[16];
md4sum(mozilla::BitwiseCast<const uint8_t*, const char*>(params.data),
strlen(params.data), actualHash);
- EXPECT_TRUE(mozilla::PodEqual(actualHash, params.expectedHash))
+ EXPECT_TRUE(mozilla::ArrayEqual(actualHash, params.expectedHash))
<< "MD4 hashes aren't equal for input: '" << params.data << "'";
}
INSTANTIATE_TEST_CASE_P(psm_MD4, psm_MD4,
testing::ValuesIn(RFC1320_TEST_PARAMS));