зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1470985 - s/PodEqual/ArrayEqual/ from ArrayUtils.h. - r=waldo
We can't use memcmp to compare PODs, largely because of undefined padding. The rest of the Pod* functions are fine though, since we're replicating or zeroing PODs. MozReview-Commit-ID: LSspAi8qCWw
This commit is contained in:
Родитель
a7d855f037
Коммит
0e128a3868
|
@ -11,6 +11,7 @@
|
|||
#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"
|
||||
|
@ -92,7 +93,7 @@ struct WebIDLNameTableEntry : public PLDHashEntryHdr
|
|||
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,
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#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
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#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"
|
||||
|
@ -763,7 +764,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
|
|||
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();
|
||||
}
|
||||
|
@ -974,7 +975,7 @@ FilterNodeFromPrimitiveDescription(const FilterPrimitiveDescription& aDescriptio
|
|||
// 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,
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* 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;
|
||||
|
@ -50,17 +50,17 @@ TEST(Moz2D, PremultiplyData) {
|
|||
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) {
|
||||
|
@ -103,17 +103,17 @@ TEST(Moz2D, UnpremultiplyData) {
|
|||
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) {
|
||||
|
@ -199,42 +199,42 @@ TEST(Moz2D, SwizzleData) {
|
|||
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));
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "jit/CacheIRCompiler.h"
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
|
||||
#include <utility>
|
||||
|
@ -1165,7 +1166,7 @@ CacheIRStubKey::match(const CacheIRStubKey& entry, const CacheIRStubKey::Lookup&
|
|||
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;
|
||||
|
|
|
@ -3,12 +3,11 @@
|
|||
* 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'
|
||||
|
@ -27,7 +26,7 @@ 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) {
|
||||
|
|
|
@ -127,14 +127,13 @@ 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;
|
||||
|
||||
|
@ -2074,7 +2073,7 @@ Evaluate(JSContext* cx, unsigned argc, Value* vp)
|
|||
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;
|
||||
|
@ -5582,7 +5581,7 @@ SingleStepCallback(void* arg, jit::Simulator* sim, void* pc)
|
|||
// 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");
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef util_Text_h
|
||||
#define util_Text_h
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/TextUtils.h"
|
||||
|
@ -62,7 +63,7 @@ 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>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "vm/Iteration.h"
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
|
@ -47,10 +48,10 @@
|
|||
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;
|
||||
|
||||
|
@ -793,8 +794,8 @@ IteratorHashPolicy::match(PropertyIteratorObject* obj, const Lookup& lookup)
|
|||
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
|
||||
|
|
|
@ -96,14 +96,14 @@ js::AtomHasher::match(const AtomStateEntry& entry, const Lookup& lookup)
|
|||
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*
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
#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"
|
||||
|
@ -886,7 +886,7 @@ struct ScriptBytecodeHasher
|
|||
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());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "vm/StringType-inl.h"
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/HashFunctions.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
|
@ -30,11 +31,11 @@
|
|||
|
||||
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;
|
||||
|
@ -846,13 +847,13 @@ js::EqualChars(JSLinearString* str1, JSLinearString* str2)
|
|||
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);
|
||||
}
|
||||
|
@ -868,14 +869,14 @@ js::HasSubstringAt(JSLinearString* text, JSLinearString* pat, size_t start)
|
|||
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);
|
||||
}
|
||||
|
@ -991,7 +992,7 @@ js::StringEqualsAscii(JSLinearString* str, const char* asciiBytes)
|
|||
|
||||
AutoCheckCannotGC nogc;
|
||||
return str->hasLatin1Chars()
|
||||
? PodEqual(latin1, str->latin1Chars(nogc), length)
|
||||
? ArrayEqual(latin1, str->latin1Chars(nogc), length)
|
||||
: EqualChars(latin1, str->twoByteChars(nogc), length);
|
||||
}
|
||||
|
||||
|
@ -1757,7 +1758,7 @@ ExternalStringCache::lookup(const char16_t* chars, size_t len) const
|
|||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "vm/Xdr.h"
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
|
||||
|
@ -21,7 +22,7 @@
|
|||
#include "vm/TraceLogging.h"
|
||||
|
||||
using namespace js;
|
||||
using mozilla::PodEqual;
|
||||
using mozilla::ArrayEqual;
|
||||
|
||||
template<XDRMode mode>
|
||||
LifoAlloc&
|
||||
|
@ -116,7 +117,7 @@ VersionCheck(XDRState<mode>* xdr)
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "wasm/AsmJS.h"
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Compression.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
|
@ -58,6 +59,7 @@ 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;
|
||||
|
@ -65,7 +67,6 @@ using mozilla::IsNaN;
|
|||
using mozilla::IsNegativeZero;
|
||||
using mozilla::IsPositiveZero;
|
||||
using mozilla::IsPowerOfTwo;
|
||||
using mozilla::PodEqual;
|
||||
using mozilla::PodZero;
|
||||
using mozilla::PositiveInfinity;
|
||||
using mozilla::Unused;
|
||||
|
@ -6827,7 +6828,7 @@ class ModuleCharsForLookup : ModuleChars
|
|||
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;
|
||||
|
|
|
@ -541,7 +541,7 @@ 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
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define wasm_types_h
|
||||
|
||||
#include "mozilla/Alignment.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/EnumeratedArray.h"
|
||||
#include "mozilla/HashFunctions.h"
|
||||
|
@ -75,6 +76,7 @@ typedef Rooted<WasmGlobalObject*> RootedWasmGlobalObject;
|
|||
|
||||
namespace wasm {
|
||||
|
||||
using mozilla::ArrayEqual;
|
||||
using mozilla::Atomic;
|
||||
using mozilla::DebugOnly;
|
||||
using mozilla::EnumeratedArray;
|
||||
|
@ -83,7 +85,6 @@ using mozilla::MallocSizeOf;
|
|||
using mozilla::Nothing;
|
||||
using mozilla::PodZero;
|
||||
using mozilla::PodCopy;
|
||||
using mozilla::PodEqual;
|
||||
using mozilla::Some;
|
||||
using mozilla::Unused;
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#define nsCSSPropertyIDSet_h__
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
|
||||
#include "nsCSSPropertyID.h"
|
||||
#include <limits.h> // for CHAR_BIT
|
||||
|
@ -64,7 +63,7 @@ public:
|
|||
}
|
||||
|
||||
bool Equals(const nsCSSPropertyIDSet& aOther) const {
|
||||
return mozilla::PodEqual(mProperties, aOther.mProperties);
|
||||
return mozilla::ArrayEqual(mProperties, aOther.mProperties);
|
||||
}
|
||||
|
||||
bool IsEmpty() const {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -98,6 +99,24 @@ 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,
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -158,38 +159,9 @@ PodMove(T* aDst, const T* aSrc, size_t aNElem)
|
|||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
|
|
|
@ -1102,17 +1102,17 @@ CertIsAuthoritativeForEVPolicy(const UniqueCERTCertificate& cert,
|
|||
// 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;
|
||||
}
|
||||
}
|
||||
|
@ -1188,7 +1188,7 @@ LoadExtendedValidationInfo()
|
|||
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;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "nsNSSCertificate.h"
|
||||
#include "nsNSSCertValidity.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -29,7 +29,7 @@ CertDNIsInList(const CERTCertificate* aCert, const DataAndLength (&aDnList)[T])
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ CertSPKIIsInList(const CERTCertificate* aCert, const DataAndLength (&aSpkiList)[
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -64,9 +64,9 @@ CertMatchesStaticData(const CERTCertificate* 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.
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include "gtest/gtest.h"
|
||||
#include "md4.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Casting.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
|
||||
struct RFC1320TestParams
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ TEST_P(psm_MD4, RFC1320TestValues)
|
|||
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 << "'";
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче