Bug 1572013 - Use mozilla::Array instead of mozilla::Vector for static array. r=Yoric

Differential Revision: https://phabricator.services.mozilla.com/D44448

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tooru Fujisawa 2019-09-03 12:29:47 +00:00
parent 4276bb6342
commit 739be72b65
2 changed files with 10 additions and 16 deletions

View File

@ -2186,18 +2186,10 @@ HuffmanPreludeReader::readSingleValueTable<UnsignedLong>(
}
HuffmanDictionary::HuffmanDictionary(JSContext* cx)
: fields(cx), listLengths(cx) {
// Initialize `fields`. We have reserved space statically, this cannot fail.
for (size_t i = 0; i < BINAST_INTERFACE_AND_FIELD_LIMIT; ++i) {
fields.infallibleEmplaceBack(HuffmanTableUnreachable{});
}
// Initialize `listLengths`. We have reserved space statically, this cannot
// fail.
for (size_t i = 0; i < BINAST_NUMBER_OF_LIST_TYPES; ++i) {
listLengths.infallibleEmplaceBack(HuffmanTableUnreachable{});
}
}
: fields(BINAST_PARAM_NUMBER_OF_INTERFACE_AND_FIELD(
mozilla::AsVariant(HuffmanTableUnreachable()))),
listLengths(BINAST_PARAM_NUMBER_OF_LIST_TYPES(
mozilla::AsVariant(HuffmanTableUnreachable()))) {}
HuffmanTable& HuffmanDictionary::tableForField(
NormalizedInterfaceAndField index) {

View File

@ -7,10 +7,11 @@
#ifndef frontend_BinASTTokenReaderContext_h
#define frontend_BinASTTokenReaderContext_h
#include "mozilla/Array.h" // mozilla::Array
#include "mozilla/Assertions.h" // MOZ_ASSERT
#include "mozilla/Attributes.h" // MOZ_MUST_USE, MOZ_STACK_CLASS
#include "mozilla/Maybe.h" // mozilla::Maybe
#include "mozilla/Maybe.h" // mozilla::Maybe
#include "mozilla/Variant.h" // mozilla::Variant
#include <stddef.h> // size_t
#include <stdint.h> // uint8_t, uint32_t
@ -324,7 +325,7 @@ class HuffmanDictionary {
//
// The mapping from `(Interface, Field) -> index` is extracted statically from
// the webidl specs.
Vector<HuffmanTable, BINAST_INTERFACE_AND_FIELD_LIMIT> fields;
mozilla::Array<HuffmanTable, BINAST_INTERFACE_AND_FIELD_LIMIT> fields;
// Huffman tables for list lengths. Some tables may be
// `HuffmanTableUnreacheable` if they represent lists that actually do not
@ -332,7 +333,8 @@ class HuffmanDictionary {
//
// The mapping from `List -> index` is extracted statically from the webidl
// specs.
Vector<HuffmanTableListLength, BINAST_NUMBER_OF_LIST_TYPES> listLengths;
mozilla::Array<HuffmanTableListLength, BINAST_NUMBER_OF_LIST_TYPES>
listLengths;
};
/**