Bug 1922838 - Replace ArrayLength, ArrayEnd and MOZ_ARRAY_LENGTH by standard alternative r=glandium,necko-reviewers,jgilbert,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,anti-tracking-reviewers,places-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,bytesized,janv,dimi,daisuke,karlt,gstoll,canaltinova,timhuang

Namely std::size, std::end and std::size. This drops C support for
MOZ_ARRAY_LENGTH but it wasn't used anyway.

Differential Revision: https://phabricator.services.mozilla.com/D224611
This commit is contained in:
serge-sans-paille 2024-10-24 09:06:01 +00:00
Родитель 5fe0ba685f
Коммит 53068cdf31
370 изменённых файлов: 1115 добавлений и 1277 удалений

Просмотреть файл

@ -391,7 +391,7 @@ static GType GetMaiAtkType(uint16_t interfacesBits) {
type = g_type_register_static(MAI_TYPE_ATK_OBJECT, atkTypeName, &tinfo,
GTypeFlags(0));
for (uint32_t index = 0; index < ArrayLength(atk_if_infos); index++) {
for (uint32_t index = 0; index < std::size(atk_if_infos); index++) {
if (interfacesBits & (1 << index)) {
g_type_add_interface_static(type,
GetAtkTypeForMai((MaiInterfaceType)index),

Просмотреть файл

@ -550,7 +550,7 @@ void textInterfaceInitCB(AtkTextIface* aIface) {
}
// Cache the string values of the atk text attribute names.
for (uint32_t i = 0; i < ArrayLength(sAtkTextAttrNames); i++) {
for (uint32_t i = 0; i < std::size(sAtkTextAttrNames); i++) {
sAtkTextAttrNames[i] =
atk_text_attribute_get_name(static_cast<AtkTextAttribute>(i));
}

Просмотреть файл

@ -1531,7 +1531,7 @@ uint8_t aria::GetFirstValidRoleMapIndexExcluding(
return Compare(role, aEntry.ARIARoleString(),
nsCaseInsensitiveStringComparator);
};
if (BinarySearchIf(sWAIRoleMaps, 0, ArrayLength(sWAIRoleMaps), comparator,
if (BinarySearchIf(sWAIRoleMaps, 0, std::size(sWAIRoleMaps), comparator,
&idx)) {
return idx;
}
@ -1581,7 +1581,7 @@ bool aria::IsRoleMapIndexValid(uint8_t aRoleMapIndex) {
case LANDMARK_ROLE_MAP_ENTRY_INDEX:
return true;
}
return aRoleMapIndex < ArrayLength(sWAIRoleMaps);
return aRoleMapIndex < std::size(sWAIRoleMaps);
}
uint64_t aria::UniversalStatesFor(mozilla::dom::Element* aElement) {
@ -1593,7 +1593,7 @@ uint64_t aria::UniversalStatesFor(mozilla::dom::Element* aElement) {
}
uint8_t aria::AttrCharacteristicsFor(nsAtom* aAtom) {
for (uint32_t i = 0; i < ArrayLength(gWAIUnivAttrMap); i++) {
for (uint32_t i = 0; i < std::size(gWAIUnivAttrMap); i++) {
if (gWAIUnivAttrMap[i].attributeName == aAtom) {
return gWAIUnivAttrMap[i].characteristics;
}
@ -1615,7 +1615,7 @@ const nsRoleMapEntry* aria::GetRoleMap(const nsStaticAtom* aAriaRole) {
return Compare(role, aEntry.ARIARoleString());
};
size_t idx;
if (BinarySearchIf(sWAIRoleMaps, 0, ArrayLength(sWAIRoleMaps), comparator,
if (BinarySearchIf(sWAIRoleMaps, 0, std::size(sWAIRoleMaps), comparator,
&idx)) {
return GetRoleMapFromIndex(idx);
}

Просмотреть файл

@ -74,7 +74,7 @@ static void EnableLogging(const char* aModulesStr) {
const char* token = aModulesStr;
while (*token != '\0') {
size_t tokenLen = strcspn(token, ",");
for (unsigned int idx = 0; idx < ArrayLength(sModuleMap); idx++) {
for (unsigned int idx = 0; idx < std::size(sModuleMap); idx++) {
if (strncmp(token, sModuleMap[idx].mStr, tokenLen) == 0) {
#if !defined(MOZ_PROFILING) && (!defined(DEBUG) || defined(MOZ_OPTIMIZE))
// Stack tracing on profiling enabled or debug not optimized builds.
@ -977,7 +977,7 @@ bool logging::IsEnabledAll(uint32_t aModules) {
}
bool logging::IsEnabled(const nsAString& aModuleStr) {
for (unsigned int idx = 0; idx < ArrayLength(sModuleMap); idx++) {
for (unsigned int idx = 0; idx < std::size(sModuleMap); idx++) {
if (aModuleStr.EqualsASCII(sModuleMap[idx].mStr)) {
return sModules & sModuleMap[idx].mModule;
}

Просмотреть файл

@ -127,14 +127,14 @@ void TextAttrsMgr::GetAttributes(AccAttributes* aAttributes,
// Expose text attributes if applicable.
if (aAttributes) {
for (uint32_t idx = 0; idx < ArrayLength(attrArray); idx++) {
for (uint32_t idx = 0; idx < std::size(attrArray); idx++) {
attrArray[idx]->Expose(aAttributes, mIncludeDefAttrs);
}
}
// Expose text attributes range where they are applied if applicable.
if (aStartOffset) {
GetRange(attrArray, ArrayLength(attrArray), aStartOffset, aEndOffset);
GetRange(attrArray, std::size(attrArray), aStartOffset, aEndOffset);
}
}

Просмотреть файл

@ -470,7 +470,7 @@ FindDOMTextOffsetAttributes(LocalAccessible* aAcc, int32_t aRenderedStart,
{SelectionType::eSpellCheck, nsGkAtoms::spelling},
{SelectionType::eTargetText, nsGkAtoms::mark},
};
result.SetCapacity(ArrayLength(kSelectionTypesToAttributes));
result.SetCapacity(std::size(kSelectionTypesToAttributes));
for (auto [selType, attr] : kSelectionTypesToAttributes) {
dom::Selection* domSel = frameSel->GetSelection(selType);
if (!domSel) {

Просмотреть файл

@ -453,9 +453,9 @@ uint64_t nsAccessibilityService::gCacheDomains =
nsAccessibilityService::kDefaultCacheDomains;
nsAccessibilityService::nsAccessibilityService()
: mHTMLMarkupMap(ArrayLength(sHTMLMarkupMapList)),
mMathMLMarkupMap(ArrayLength(sMathMLMarkupMapList)),
mXULMarkupMap(ArrayLength(sXULMarkupMapList)) {}
: mHTMLMarkupMap(std::size(sHTMLMarkupMapList)),
mMathMLMarkupMap(std::size(sMathMLMarkupMapList)),
mXULMarkupMap(std::size(sXULMarkupMapList)) {}
nsAccessibilityService::~nsAccessibilityService() {
NS_ASSERTION(IsShutdown(), "Accessibility wasn't shutdown!");
@ -1082,10 +1082,10 @@ already_AddRefed<DOMStringList> nsAccessibilityService::GetStringStates(
void nsAccessibilityService::GetStringEventType(uint32_t aEventType,
nsAString& aString) {
static_assert(
nsIAccessibleEvent::EVENT_LAST_ENTRY == ArrayLength(kEventTypeNames),
nsIAccessibleEvent::EVENT_LAST_ENTRY == std::size(kEventTypeNames),
"nsIAccessibleEvent constants are out of sync to kEventTypeNames");
if (aEventType >= ArrayLength(kEventTypeNames)) {
if (aEventType >= std::size(kEventTypeNames)) {
aString.AssignLiteral("unknown");
return;
}
@ -1095,11 +1095,10 @@ void nsAccessibilityService::GetStringEventType(uint32_t aEventType,
void nsAccessibilityService::GetStringEventType(uint32_t aEventType,
nsACString& aString) {
MOZ_ASSERT(
nsIAccessibleEvent::EVENT_LAST_ENTRY == ArrayLength(kEventTypeNames),
"nsIAccessibleEvent constants are out of sync to kEventTypeNames");
MOZ_ASSERT(nsIAccessibleEvent::EVENT_LAST_ENTRY == std::size(kEventTypeNames),
"nsIAccessibleEvent constants are out of sync to kEventTypeNames");
if (aEventType >= ArrayLength(kEventTypeNames)) {
if (aEventType >= std::size(kEventTypeNames)) {
aString.AssignLiteral("unknown");
return;
}
@ -1537,7 +1536,7 @@ bool nsAccessibilityService::Init(uint64_t aCacheDomains) {
eventListenerService->AddListenerChangeListener(this);
for (uint32_t i = 0; i < ArrayLength(sHTMLMarkupMapList); i++) {
for (uint32_t i = 0; i < std::size(sHTMLMarkupMapList); i++) {
mHTMLMarkupMap.InsertOrUpdate(sHTMLMarkupMapList[i].tag,
&sHTMLMarkupMapList[i]);
}
@ -1545,7 +1544,7 @@ bool nsAccessibilityService::Init(uint64_t aCacheDomains) {
mMathMLMarkupMap.InsertOrUpdate(info.tag, &info);
}
for (uint32_t i = 0; i < ArrayLength(sXULMarkupMapList); i++) {
for (uint32_t i = 0; i < std::size(sXULMarkupMapList); i++) {
mXULMarkupMap.InsertOrUpdate(sXULMarkupMapList[i].tag,
&sXULMarkupMapList[i]);
}
@ -1756,7 +1755,7 @@ void nsAccessibilityService::MarkupAttributes(
if (!markupMap) return;
dom::Element* el = aAcc->IsLocal() ? aAcc->AsLocal()->Elm() : nullptr;
for (uint32_t i = 0; i < ArrayLength(markupMap->attrs); i++) {
for (uint32_t i = 0; i < std::size(markupMap->attrs); i++) {
const MarkupAttrInfo* info = markupMap->attrs + i;
if (!info->name) break;

Просмотреть файл

@ -311,7 +311,7 @@ class nsAccessibilityService final : public mozilla::a11y::DocManager,
const mozilla::a11y::MarkupMapInfo* markupMap =
GetMarkupMapInfoFor(aSource);
if (markupMap) {
for (size_t i = 0; i < mozilla::ArrayLength(markupMap->attrs); i++) {
for (size_t i = 0; i < std::size(markupMap->attrs); i++) {
const mozilla::a11y::MarkupAttrInfo* info = markupMap->attrs + i;
if (info->name == aAtom) {
return info->value;

Просмотреть файл

@ -65,7 +65,7 @@ static nsStaticAtom* const kRelationAttrs[] = {
nsGkAtoms::aria_errormessage, nsGkAtoms::_for,
nsGkAtoms::control, nsGkAtoms::popovertarget};
static const uint32_t kRelationAttrsLen = ArrayLength(kRelationAttrs);
static const uint32_t kRelationAttrsLen = std::size(kRelationAttrs);
static nsStaticAtom* const kSingleElementRelationIdlAttrs[] = {
nsGkAtoms::popovertarget};

Просмотреть файл

@ -153,7 +153,7 @@ nsresult RootAccessible::AddEventListeners() {
if (nstarget) {
for (const char *const *e = kEventTypes, *const *e_end =
ArrayEnd(kEventTypes);
std::end(kEventTypes);
e < e_end; ++e) {
nsresult rv = nstarget->AddEventListener(NS_ConvertASCIItoUTF16(*e), this,
true, true);
@ -169,7 +169,7 @@ nsresult RootAccessible::RemoveEventListeners() {
nsCOMPtr<EventTarget> target = window ? window->GetParentTarget() : nullptr;
if (target) {
for (const char *const *e = kEventTypes, *const *e_end =
ArrayEnd(kEventTypes);
std::end(kEventTypes);
e < e_end; ++e) {
target->RemoveEventListener(NS_ConvertASCIItoUTF16(*e), this, true);
}

Просмотреть файл

@ -1234,7 +1234,7 @@ nsTArray<bool> RemoteAccessible::PreProcessRelations(AccAttributes* aFields) {
if (!DomainsAreActive(CacheDomain::Relations)) {
return {};
}
nsTArray<bool> updateTracker(ArrayLength(kRelationTypeAtoms));
nsTArray<bool> updateTracker(std::size(kRelationTypeAtoms));
for (auto const& data : kRelationTypeAtoms) {
if (data.mValidTag) {
// The relation we're currently processing only applies to particular
@ -1310,7 +1310,7 @@ void RemoteAccessible::PostProcessRelations(const nsTArray<bool>& aToUpdate) {
return;
}
size_t updateCount = aToUpdate.Length();
MOZ_ASSERT(updateCount == ArrayLength(kRelationTypeAtoms),
MOZ_ASSERT(updateCount == std::size(kRelationTypeAtoms),
"Did not note update status for every relation type!");
for (size_t i = 0; i < updateCount; i++) {
if (aToUpdate.ElementAt(i)) {

Просмотреть файл

@ -468,7 +468,7 @@ struct RoleDescrComparator {
if (subrole) {
size_t idx = 0;
if (BinarySearchIf(sRoleDescrMap, 0, ArrayLength(sRoleDescrMap),
if (BinarySearchIf(sRoleDescrMap, 0, std::size(sRoleDescrMap),
RoleDescrComparator(subrole), &idx)) {
return utils::LocalizedString(sRoleDescrMap[idx].description);
}

Просмотреть файл

@ -77,7 +77,7 @@ ia2Accessible::get_nRelations(long* aNRelations) {
return CO_E_OBJNOTCONNECTED;
}
for (uint32_t idx = 0; idx < ArrayLength(sRelationTypePairs); idx++) {
for (uint32_t idx = 0; idx < std::size(sRelationTypePairs); idx++) {
if (sRelationTypePairs[idx].second == IA2_RELATION_NULL) continue;
Relation rel = acc->RelationByType(sRelationTypePairs[idx].first);
@ -98,7 +98,7 @@ ia2Accessible::get_relation(long aRelationIndex,
}
long relIdx = 0;
for (uint32_t idx = 0; idx < ArrayLength(sRelationTypePairs); idx++) {
for (uint32_t idx = 0; idx < std::size(sRelationTypePairs); idx++) {
if (sRelationTypePairs[idx].second == IA2_RELATION_NULL) continue;
RelationType relationType = sRelationTypePairs[idx].first;
@ -131,7 +131,7 @@ ia2Accessible::get_relations(long aMaxRelations,
}
for (uint32_t idx = 0;
idx < ArrayLength(sRelationTypePairs) && *aNRelations < aMaxRelations;
idx < std::size(sRelationTypePairs) && *aNRelations < aMaxRelations;
idx++) {
if (sRelationTypePairs[idx].second == IA2_RELATION_NULL) continue;
@ -484,7 +484,7 @@ ia2Accessible::get_relationTargetsOfType(BSTR aType, long aMaxTargets,
*aNTargets = 0;
Maybe<RelationType> relationType;
for (uint32_t idx = 0; idx < ArrayLength(sRelationTypePairs); idx++) {
for (uint32_t idx = 0; idx < std::size(sRelationTypePairs); idx++) {
if (wcscmp(aType, sRelationTypePairs[idx].second) == 0) {
relationType.emplace(sRelationTypePairs[idx].first);
break;

Просмотреть файл

@ -210,7 +210,7 @@ bool LazyInstantiator::IsBlockedInjection() {
return false;
}
for (size_t index = 0, len = ArrayLength(gBlockedInprocDlls); index < len;
for (size_t index = 0, len = std::size(gBlockedInprocDlls); index < len;
++index) {
const DllBlockInfo& blockedDll = gBlockedInprocDlls[index];
HMODULE module = ::GetModuleHandleW(blockedDll.mName);
@ -247,8 +247,7 @@ bool LazyInstantiator::ShouldInstantiate(const DWORD aClientPid) {
nsAutoString leafName;
rv = clientExe->GetLeafName(leafName);
if (NS_SUCCEEDED(rv)) {
for (size_t i = 0, len = ArrayLength(gBlockedRemoteClients); i < len;
++i) {
for (size_t i = 0, len = std::size(gBlockedRemoteClients); i < len; ++i) {
if (leafName.EqualsIgnoreCase(gBlockedRemoteClients[i])) {
// If client exe is in our blocklist, do not instantiate.
return false;

Просмотреть файл

@ -216,7 +216,7 @@ void MsaaAccessible::FireWinEvent(Accessible* aTarget, uint32_t aEventType) {
nsIAccessibleEvent::EVENT_LAST_ENTRY,
"MSAA event map skewed");
if (aEventType == 0 || aEventType >= ArrayLength(gWinEventMap)) {
if (aEventType == 0 || aEventType >= std::size(gWinEventMap)) {
MOZ_ASSERT_UNREACHABLE("invalid event type");
return;
}

Просмотреть файл

@ -318,7 +318,7 @@ uiaRawElmProvider::GetRuntimeId(__RPC__deref_out_opt SAFEARRAY** aRuntimeIds) {
*aRuntimeIds = SafeArrayCreateVector(VT_I4, 0, 2);
if (!*aRuntimeIds) return E_OUTOFMEMORY;
for (LONG i = 0; i < (LONG)ArrayLength(ids); i++)
for (LONG i = 0; i < (LONG)std::size(ids); i++)
SafeArrayPutElement(*aRuntimeIds, &i, (void*)&(ids[i]));
return S_OK;

Просмотреть файл

@ -92,8 +92,7 @@ __attribute__((constructor)) static void SSE2Check() {
// Using write() in order to avoid jemalloc-based buffering. Ignoring return
// values, since there isn't much we could do on failure and there is no
// point in trying to recover from errors.
MOZ_UNUSED(
write(STDERR_FILENO, sSSE2Message, MOZ_ARRAY_LENGTH(sSSE2Message) - 1));
MOZ_UNUSED(write(STDERR_FILENO, sSSE2Message, std::size(sSSE2Message) - 1));
// _exit() instead of exit() to avoid running the usual "at exit" code.
_exit(255);
}

Просмотреть файл

@ -305,7 +305,7 @@ static bool AddWscInfo(mozilla::JSONWriter& aJson) {
const CLSID clsid = __uuidof(WSCProductList);
const IID iid = __uuidof(IWSCProductList);
for (uint32_t index = 0; index < mozilla::ArrayLength(gProvKeys); ++index) {
for (uint32_t index = 0; index < std::size(gProvKeys); ++index) {
// NB: A separate instance of IWSCProductList is needed for each distinct
// security provider type; MSDN says that we cannot reuse the same object
// and call Initialize() to pave over the previous data.
@ -368,11 +368,11 @@ static bool AddModuleInfo(const nsAutoHandle& aSnapshot,
wchar_t leaf[_MAX_FNAME] = {};
if (::_wsplitpath_s(module.szExePath, nullptr, 0, nullptr, 0, leaf,
mozilla::ArrayLength(leaf), nullptr, 0)) {
std::size(leaf), nullptr, 0)) {
return false;
}
if (_wcslwr_s(leaf, mozilla::ArrayLength(leaf))) {
if (_wcslwr_s(leaf, std::size(leaf))) {
return false;
}
@ -487,8 +487,7 @@ static bool PrepPing(const PingThreadContext& aContext, const std::wstring& aId,
tm gmTm;
if (!gmtime_s(&gmTm, &now)) {
char isoTimeBuf[32] = {};
if (strftime(isoTimeBuf, mozilla::ArrayLength(isoTimeBuf), "%FT%T.000Z",
&gmTm)) {
if (strftime(isoTimeBuf, std::size(isoTimeBuf), "%FT%T.000Z", &gmTm)) {
aJson.StringProperty("creationDate", isoTimeBuf);
}
}
@ -533,7 +532,7 @@ static bool PrepPing(const PingThreadContext& aContext, const std::wstring& aId,
WCHAR localeName[LOCALE_NAME_MAX_LENGTH] = {};
int localeNameLen =
::GetUserDefaultLocaleName(localeName, mozilla::ArrayLength(localeName));
::GetUserDefaultLocaleName(localeName, std::size(localeName));
if (localeNameLen) {
auto localeNameUtf8 = WideToUTF8(localeName, localeNameLen - 1);
if (localeNameUtf8) {
@ -647,19 +646,19 @@ static bool DoSendPing(const PingThreadContext& aContext) {
wchar_t drive[_MAX_DRIVE] = {};
wchar_t dir[_MAX_DIR] = {};
if (_wsplitpath_s(exePath.get(), drive, mozilla::ArrayLength(drive), dir,
mozilla::ArrayLength(dir), nullptr, 0, nullptr, 0)) {
if (_wsplitpath_s(exePath.get(), drive, std::size(drive), dir, std::size(dir),
nullptr, 0, nullptr, 0)) {
return false;
}
wchar_t pingSenderPath[MAX_PATH + 1] = {};
if (_wmakepath_s(pingSenderPath, mozilla::ArrayLength(pingSenderPath), drive,
dir, L"pingsender", L"exe")) {
if (_wmakepath_s(pingSenderPath, std::size(pingSenderPath), drive, dir,
L"pingsender", L"exe")) {
return false;
}
// Construct the telemetry URL
wchar_t urlBuf[mozilla::ArrayLength(kUrl) + kGuidCharLenNoBracesNoNul] = {};
wchar_t urlBuf[std::size(kUrl) + kGuidCharLenNoBracesNoNul] = {};
if (wcscpy_s(urlBuf, kUrl)) {
return false;
}
@ -672,8 +671,8 @@ static bool DoSendPing(const PingThreadContext& aContext) {
wchar_t* pingSenderArgv[] = {pingSenderPath, urlBuf,
const_cast<wchar_t*>(fileName.c_str())};
mozilla::UniquePtr<wchar_t[]> pingSenderCmdLine(mozilla::MakeCommandLine(
mozilla::ArrayLength(pingSenderArgv), pingSenderArgv));
mozilla::UniquePtr<wchar_t[]> pingSenderCmdLine(
mozilla::MakeCommandLine(std::size(pingSenderArgv), pingSenderArgv));
// Now start pingsender to handle the rest
PROCESS_INFORMATION pi;

Просмотреть файл

@ -109,7 +109,7 @@ static mozilla::LauncherResult<bool> IsAdminByAppCompat(
wchar_t* tokenContext = nullptr;
const wchar_t* token = wcstok_s(valueData.get(), kDelimiters, &tokenContext);
while (token) {
if (!_wcsnicmp(token, kRunAsAdmin, mozilla::ArrayLength(kRunAsAdmin))) {
if (!_wcsnicmp(token, kRunAsAdmin, std::size(kRunAsAdmin))) {
return true;
}
token = wcstok_s(nullptr, kDelimiters, &tokenContext);

Просмотреть файл

@ -24,7 +24,7 @@ class ProcessImagePath final {
// Initialize with an NT path string of a given process handle
explicit ProcessImagePath(const nsAutoHandle& aProcess)
: mType(PathType::eNtPath), mLastError(Ok()) {
DWORD len = mozilla::ArrayLength(mPathBuffer);
DWORD len = std::size(mPathBuffer);
if (!::QueryFullProcessImageNameW(aProcess.get(), PROCESS_NAME_NATIVE,
mPathBuffer, &len)) {
mLastError = LAUNCHER_ERROR_FROM_LAST();
@ -35,9 +35,9 @@ class ProcessImagePath final {
// Initizlize with a DOS path string of a given imagebase address
explicit ProcessImagePath(HMODULE aImageBase)
: mType(PathType::eDosPath), mLastError(Ok()) {
DWORD len = ::GetModuleFileNameW(aImageBase, mPathBuffer,
mozilla::ArrayLength(mPathBuffer));
if (!len || len == mozilla::ArrayLength(mPathBuffer)) {
DWORD len =
::GetModuleFileNameW(aImageBase, mPathBuffer, std::size(mPathBuffer));
if (!len || len == std::size(mPathBuffer)) {
mLastError = LAUNCHER_ERROR_FROM_LAST();
return;
}

Просмотреть файл

@ -117,10 +117,10 @@ void NativeNtBlockSet::Write(WritableBuffer& aBuffer) {
parts[1] = (entry->mVersion >> 32) & 0xFFFF;
parts[2] = (entry->mVersion >> 16) & 0xFFFF;
parts[3] = entry->mVersion & 0xFFFF;
for (size_t p = 0; p < mozilla::ArrayLength(parts); ++p) {
for (size_t p = 0; p < std::size(parts); ++p) {
_ltoa_s(parts[p], buf, sizeof(buf), 10);
aBuffer.Write(buf, strlen(buf));
if (p != mozilla::ArrayLength(parts) - 1) {
if (p != std::size(parts) - 1) {
aBuffer.Write(".", 1);
}
}

Просмотреть файл

@ -79,7 +79,7 @@ class TempFile final {
public:
TempFile() : mFullPath{0} {
wchar_t tempDir[MAX_PATH + 1];
DWORD len = ::GetTempPathW(ArrayLength(tempDir), tempDir);
DWORD len = ::GetTempPathW(std::size(tempDir), tempDir);
if (!len) {
return;
}
@ -537,8 +537,7 @@ class ChildProcess final {
ChildProcess(const wchar_t* aExecutable, const wchar_t* aOption)
: mProcessId(0) {
const wchar_t* childArgv[] = {aExecutable, aOption};
auto cmdLine(
mozilla::MakeCommandLine(mozilla::ArrayLength(childArgv), childArgv));
auto cmdLine(mozilla::MakeCommandLine(std::size(childArgv), childArgv));
STARTUPINFOW si = {sizeof(si)};
PROCESS_INFORMATION pi;

Просмотреть файл

@ -158,8 +158,8 @@ static nsReturnRef<HANDLE> CreateSelfProcess(int argc, wchar_t* argv[]) {
wchar_t* extraArgs[] = {strPid};
auto cmdLine = mozilla::MakeCommandLine(
argc, argv, mozilla::ArrayLength(extraArgs), extraArgs);
auto cmdLine =
mozilla::MakeCommandLine(argc, argv, std::size(extraArgs), extraArgs);
if (!cmdLine) {
PrintErrorMsg("MakeCommandLine failed");
return empty.out();

Просмотреть файл

@ -29,7 +29,7 @@
static bool IsWindowsLogonConnected() {
WCHAR userName[UNLEN + 1];
DWORD size = mozilla::ArrayLength(userName);
DWORD size = std::size(userName);
if (!GetUserNameW(userName, &size)) {
return false;
}

Просмотреть файл

@ -400,7 +400,7 @@ bool CheckBrowserUserChoiceHashes() {
const wchar_t* exts[] = {L"https", L"http", L".html", L".htm"};
for (size_t i = 0; i < ArrayLength(exts); ++i) {
for (size_t i = 0; i < std::size(exts); ++i) {
switch (CheckUserChoiceHash(exts[i], userSid.get())) {
case CheckUserChoiceHashResult::OK_V1:
break;

Просмотреть файл

@ -206,7 +206,7 @@ nsGNOMEShellService::IsDefaultBrowser(bool aForAllTypes,
nsAutoCString handler;
nsCOMPtr<nsIGIOMimeApp> gioApp;
for (unsigned int i = 0; i < ArrayLength(appProtocols); ++i) {
for (unsigned int i = 0; i < std::size(appProtocols); ++i) {
if (!appProtocols[i].essential) continue;
if (!IsDefaultForSchemeHelper(nsDependentCString(appProtocols[i].name),
@ -298,7 +298,7 @@ nsGNOMEShellService::SetDefaultBrowser(bool aForAllUsers) {
}
// set handler for the protocols
for (unsigned int i = 0; i < ArrayLength(appProtocols); ++i) {
for (unsigned int i = 0; i < std::size(appProtocols); ++i) {
appInfo->SetAsDefaultForURIScheme(
nsDependentCString(appProtocols[i].name));
}
@ -306,7 +306,7 @@ nsGNOMEShellService::SetDefaultBrowser(bool aForAllUsers) {
// set handler for .html and xhtml files and MIME types:
// Add mime types for html, xhtml extension and set app to just created
// appinfo.
for (unsigned int i = 0; i < ArrayLength(appTypes); ++i) {
for (unsigned int i = 0; i < std::size(appTypes); ++i) {
appInfo->SetAsDefaultForMimeType(
nsDependentCString(appTypes[i].mimeType));
appInfo->SetAsDefaultForFileExtensions(

Просмотреть файл

@ -1169,7 +1169,7 @@ static nsresult GetMatchingShortcut(int aCSIDL, const nsAString& aAUMID,
static_assert(MAXPATHLEN == MAX_PATH);
wchar_t storedExePath[MAX_PATH] = {};
// With no flags GetPath gets a long path
hr = link->GetPath(storedExePath, ArrayLength(storedExePath), nullptr, 0);
hr = link->GetPath(storedExePath, std::size(storedExePath), nullptr, 0);
if (FAILED(hr) || hr == S_FALSE) {
continue;
}
@ -1394,7 +1394,7 @@ static bool IsCurrentAppPinnedToTaskbarSync(const nsAString& aumid) {
static_assert(MAXPATHLEN == MAX_PATH);
wchar_t storedExePath[MAX_PATH] = {};
// With no flags GetPath gets a long path
hr = link->GetPath(storedExePath, ArrayLength(storedExePath), nullptr, 0);
hr = link->GetPath(storedExePath, std::size(storedExePath), nullptr, 0);
if (FAILED(hr) || hr == S_FALSE) {
continue;
}
@ -2579,7 +2579,7 @@ nsWindowsShellService::ClassifyShortcut(const nsAString& aPath,
{FOLDERID_UserPinned, u"\\TaskBar\\", u"Taskbar"},
{FOLDERID_UserPinned, u"\\StartMenu\\", u"StartMenu"}};
for (size_t i = 0; i < ArrayLength(folders); ++i) {
for (size_t i = 0; i < std::size(folders); ++i) {
nsAutoString knownPath;
// These flags are chosen to avoid I/O, see bug 1363398.

Просмотреть файл

@ -372,7 +372,7 @@ nsresult BasePrincipal::ToJSON(nsACString& aJSON) {
}
nsresult BasePrincipal::ToJSON(JSONWriter& aWriter) {
static_assert(eKindMax < ArrayLength(JSONEnumKeyStrings));
static_assert(eKindMax < std::size(JSONEnumKeyStrings));
aWriter.Start(JSONWriter::CollectionStyle::SingleLineStyle);

Просмотреть файл

@ -361,7 +361,7 @@ class BasePrincipal : public nsJSPrincipals {
protected:
template <size_t EnumValue>
static inline constexpr const Span<const char>& JSONEnumKeyString() {
static_assert(EnumValue < ArrayLength(JSONEnumKeyStrings));
static_assert(EnumValue < std::size(JSONEnumKeyStrings));
return JSONEnumKeyStrings[EnumValue];
}
template <size_t EnumValue>

Просмотреть файл

@ -1213,7 +1213,7 @@ nsScriptSecurityManager::CheckLoadURIStrWithPrincipal(
// available.
uint32_t flags[] = {nsIURIFixup::FIXUP_FLAG_NONE,
nsIURIFixup::FIXUP_FLAG_FIX_SCHEME_TYPOS};
for (uint32_t i = 0; i < ArrayLength(flags); ++i) {
for (uint32_t i = 0; i < std::size(flags); ++i) {
uint32_t fixupFlags = flags[i];
if (aPrincipal->OriginAttributesRef().IsPrivateBrowsing()) {
fixupFlags |= nsIURIFixup::FIXUP_FLAG_PRIVATE_CONTEXT;

Просмотреть файл

@ -212,7 +212,7 @@ static const RedirEntry kRedirMap[] = {
nsIAboutModule::URI_MUST_LOAD_IN_CHILD},
{"crashgpu", "about:blank", nsIAboutModule::HIDE_FROM_ABOUTABOUT},
{"crashextensions", "about:blank", nsIAboutModule::HIDE_FROM_ABOUTABOUT}};
static const int kRedirTotal = mozilla::ArrayLength(kRedirMap);
static const int kRedirTotal = std::size(kRedirMap);
NS_IMETHODIMP
nsAboutRedirector::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,

Просмотреть файл

@ -782,9 +782,8 @@ CCRunnerStep CCGCScheduler::AdvanceCCRunner(TimeStamp aDeadline, TimeStamp aNow,
{false, false}, /* CCRunnerState::StartCycleCollection */
{false, false}, /* CCRunnerState::CycleCollecting */
{false, false}}; /* CCRunnerState::Canceled */
static_assert(
ArrayLength(stateDescriptors) == size_t(CCRunnerState::NumStates),
"need one state descriptor per state");
static_assert(std::size(stateDescriptors) == size_t(CCRunnerState::NumStates),
"need one state descriptor per state");
const StateDescriptor& desc = stateDescriptors[int(mCCRunnerState)];
// Make sure we initialized the state machine.

Просмотреть файл

@ -99,7 +99,7 @@ static void NSResultToNameAndMessage(nsresult aNSResult, nsCString& aName,
aName.Truncate();
aMessage.Truncate();
*aCode = 0;
for (uint32_t idx = 0; idx < ArrayLength(sDOMErrorMsgMap); idx++) {
for (uint32_t idx = 0; idx < std::size(sDOMErrorMsgMap); idx++) {
if (aNSResult == sDOMErrorMsgMap[idx].mNSResult) {
aName.Rebind(sDOMErrorMsgMap[idx].mName,
strlen(sDOMErrorMsgMap[idx].mName));
@ -355,7 +355,7 @@ already_AddRefed<DOMException> DOMException::Constructor(
if (aName.WasPassed()) {
CopyUTF16toUTF8(aName.Value(), name);
for (uint32_t idx = 0; idx < ArrayLength(sDOMErrorMsgMap); idx++) {
for (uint32_t idx = 0; idx < std::size(sDOMErrorMsgMap); idx++) {
if (name.EqualsASCII(sDOMErrorMsgMap[idx].mName)) {
exceptionResult = sDOMErrorMsgMap[idx].mNSResult;
exceptionCode = sDOMErrorMsgMap[idx].mCode;

Просмотреть файл

@ -2533,7 +2533,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(Document)
static const char* kNSURIs[] = {"([none])", "(xmlns)", "(xml)",
"(xhtml)", "(XLink)", "(XSLT)",
"(MathML)", "(RDF)", "(XUL)"};
if (nsid < ArrayLength(kNSURIs)) {
if (nsid < std::size(kNSURIs)) {
SprintfLiteral(name, "Document %s %s %s", loadedAsData.get(),
kNSURIs[nsid], uri.get());
} else {

Просмотреть файл

@ -1819,13 +1819,13 @@ static inline bool IsVoidTag(nsAtom* aTag) {
static bool sInitialized = false;
if (!sInitialized) {
sInitialized = true;
for (uint32_t i = 0; i < ArrayLength(voidElements); ++i) {
for (uint32_t i = 0; i < std::size(voidElements); ++i) {
sFilter.add(voidElements[i]);
}
}
if (sFilter.mightContain(aTag)) {
for (uint32_t i = 0; i < ArrayLength(voidElements); ++i) {
for (uint32_t i = 0; i < std::size(voidElements); ++i) {
if (aTag == voidElements[i]) {
return true;
}

Просмотреть файл

@ -1022,13 +1022,13 @@ bool nsContentUtils::InitializeEventTable() {
{nullptr}};
sAtomEventTable =
new nsTHashMap<RefPtr<nsAtom>, EventNameMapping>(ArrayLength(eventArray));
sStringEventTable = new nsTHashMap<nsStringHashKey, EventNameMapping>(
ArrayLength(eventArray));
new nsTHashMap<RefPtr<nsAtom>, EventNameMapping>(std::size(eventArray));
sStringEventTable =
new nsTHashMap<nsStringHashKey, EventNameMapping>(std::size(eventArray));
sUserDefinedEvents = new nsTArray<RefPtr<nsAtom>>(64);
// Subtract one from the length because of the trailing null
for (uint32_t i = 0; i < ArrayLength(eventArray) - 1; ++i) {
for (uint32_t i = 0; i < std::size(eventArray) - 1; ++i) {
MOZ_ASSERT(!sAtomEventTable->Contains(eventArray[i].mAtom),
"Double-defining event name; fix your EventNameList.h");
sAtomEventTable->InsertOrUpdate(eventArray[i].mAtom, eventArray[i]);
@ -1053,7 +1053,7 @@ void nsContentUtils::InitializeTouchEventTable() {
#undef EVENT
{nullptr}};
// Subtract one from the length because of the trailing null
for (uint32_t i = 0; i < ArrayLength(touchEventArray) - 1; ++i) {
for (uint32_t i = 0; i < std::size(touchEventArray) - 1; ++i) {
sAtomEventTable->InsertOrUpdate(touchEventArray[i].mAtom,
touchEventArray[i]);
sStringEventTable->InsertOrUpdate(
@ -6149,7 +6149,7 @@ const nsDependentString nsContentUtils::GetLocalizedEllipsis() {
nsAutoString tmp;
Preferences::GetLocalizedString("intl.ellipsis", tmp);
uint32_t len =
std::min(uint32_t(tmp.Length()), uint32_t(ArrayLength(sBuf) - 1));
std::min(uint32_t(tmp.Length()), uint32_t(std::size(sBuf) - 1));
CopyUnicodeTo(tmp, 0, sBuf, len);
}
if (!sBuf[0]) sBuf[0] = char16_t(0x2026);
@ -9455,8 +9455,8 @@ static void AppendEncodedCharacters(const nsTextFragment* aText,
// eg < in it. We subtract 1 for the null terminator, then 1 more for the
// existing character that will be replaced.
constexpr uint32_t maxCharExtraSpace =
std::max({ArrayLength("&lt;"), ArrayLength("&gt;"),
ArrayLength("&amp;"), ArrayLength("&nbsp;")}) -
std::max({std::size("&lt;"), std::size("&gt;"), std::size("&amp;"),
std::size("&nbsp;")}) -
2;
static_assert(maxCharExtraSpace < 100, "Possible underflow");
CheckedInt<uint32_t> maxExtraSpace =
@ -9496,8 +9496,7 @@ static CheckedInt<uint32_t> ExtraSpaceNeededForAttrEncoding(
// & in it. We subtract 1 for the null terminator, then 1 more for the
// existing character that will be replaced.
constexpr uint32_t maxCharExtraSpace =
std::max({ArrayLength("&quot;"), ArrayLength("&amp;"),
ArrayLength("&nbsp;")}) -
std::max({std::size("&quot;"), std::size("&amp;"), std::size("&nbsp;")}) -
2;
static_assert(maxCharExtraSpace < 100, "Possible underflow");
return CheckedInt<uint32_t>(numEncodedChars) * maxCharExtraSpace;

Просмотреть файл

@ -3136,7 +3136,7 @@ bool nsGlobalWindowInner::ResolveComponentsShim(
// Define a bunch of shims from the Ci.nsIDOMFoo to window.Foo for DOM
// interfaces with constants.
for (uint32_t i = 0; i < ArrayLength(kInterfaceShimMap); ++i) {
for (uint32_t i = 0; i < std::size(kInterfaceShimMap); ++i) {
// Grab the names from the table.
const char* geckoName = kInterfaceShimMap[i].geckoName;
const char* domName = kInterfaceShimMap[i].domName;

Просмотреть файл

@ -910,11 +910,11 @@ static const char* NodeTypeAsString(nsINode* aNode) {
"a DocumentFragment",
"a Notation",
};
static_assert(ArrayLength(NodeTypeStrings) == nsINode::MAX_NODE_TYPE + 1,
static_assert(std::size(NodeTypeStrings) == nsINode::MAX_NODE_TYPE + 1,
"Max node type out of range for our array");
uint16_t nodeType = aNode->NodeType();
MOZ_RELEASE_ASSERT(nodeType < ArrayLength(NodeTypeStrings),
MOZ_RELEASE_ASSERT(nodeType < std::size(NodeTypeStrings),
"Uknown out-of-range node type");
return NodeTypeStrings[nodeType];
}

Просмотреть файл

@ -43,7 +43,7 @@ nsPIDOMWindowInner* nsMimeTypeArray::GetParentObject() const {
}
nsMimeType* nsMimeTypeArray::IndexedGetter(uint32_t aIndex, bool& aFound) {
if (!ForceNoPlugins() && aIndex < ArrayLength(mMimeTypes)) {
if (!ForceNoPlugins() && aIndex < std::size(mMimeTypes)) {
aFound = true;
return mMimeTypes[aIndex];
}

Просмотреть файл

@ -35,7 +35,7 @@ class nsMimeTypeArray final : public nsISupports, public nsWrapperCache {
JS::Handle<JSObject*> aGivenProto) override;
// MimeTypeArray WebIDL methods
uint32_t Length() { return ForceNoPlugins() ? 0 : ArrayLength(mMimeTypes); }
uint32_t Length() { return ForceNoPlugins() ? 0 : std::size(mMimeTypes); }
nsMimeType* Item(uint32_t aIndex) {
bool unused;

Просмотреть файл

@ -167,7 +167,7 @@ const char* nsNameSpaceManager::GetNameSpaceDisplayName(uint32_t aNameSpaceID) {
static const char* kNSURIs[] = {"([none])", "(xmlns)", "(xml)", "(xhtml)",
"(XLink)", "(XSLT)", "(MathML)", "(RDF)",
"(XUL)", "(SVG)"};
if (aNameSpaceID < ArrayLength(kNSURIs)) {
if (aNameSpaceID < std::size(kNSURIs)) {
return kNSURIs[aNameSpaceID];
}
return "";

Просмотреть файл

@ -36,12 +36,12 @@ nsPluginArray::nsPluginArray(nsPIDOMWindowInner* aWindow) : mWindow(aWindow) {
mPlugins[0] = MakeRefPtr<nsPluginElement>(this, aWindow, kMainPluginName);
mozilla::Array<RefPtr<nsMimeType>, 2> mimeTypes;
for (uint32_t i = 0; i < ArrayLength(kMimeTypeNames); ++i) {
for (uint32_t i = 0; i < std::size(kMimeTypeNames); ++i) {
mimeTypes[i] = MakeRefPtr<nsMimeType>(mPlugins[0], kMimeTypeNames[i]);
}
mMimeTypeArray = MakeRefPtr<nsMimeTypeArray>(aWindow, mimeTypes);
for (uint32_t i = 0; i < ArrayLength(kExtraPluginNames); ++i) {
for (uint32_t i = 0; i < std::size(kExtraPluginNames); ++i) {
mPlugins[i + 1] =
MakeRefPtr<nsPluginElement>(this, aWindow, kExtraPluginNames[i]);
}
@ -60,7 +60,7 @@ JSObject* nsPluginArray::WrapObject(JSContext* aCx,
}
nsPluginElement* nsPluginArray::IndexedGetter(uint32_t aIndex, bool& aFound) {
if (!ForceNoPlugins() && aIndex < ArrayLength(mPlugins)) {
if (!ForceNoPlugins() && aIndex < std::size(mPlugins)) {
aFound = true;
return mPlugins[aIndex];
}

Просмотреть файл

@ -39,7 +39,7 @@ class nsPluginArray final : public nsSupportsWeakReference,
nsMimeTypeArray* MimeTypeArray() { return mMimeTypeArray; }
// PluginArray WebIDL methods
uint32_t Length() { return ForceNoPlugins() ? 0 : ArrayLength(mPlugins); }
uint32_t Length() { return ForceNoPlugins() ? 0 : std::size(mPlugins); }
nsPluginElement* Item(uint32_t aIndex) {
bool unused;

Просмотреть файл

@ -2352,61 +2352,61 @@ void nsTreeSanitizer::LogMessage(const char* aMessage, Document* aDoc,
void nsTreeSanitizer::InitializeStatics() {
MOZ_ASSERT(!sElementsHTML, "Initializing a second time.");
sElementsHTML = new AtomsTable(ArrayLength(kElementsHTML));
sElementsHTML = new AtomsTable(std::size(kElementsHTML));
for (uint32_t i = 0; kElementsHTML[i]; i++) {
sElementsHTML->Insert(kElementsHTML[i]);
}
sAttributesHTML = new AtomsTable(ArrayLength(kAttributesHTML));
sAttributesHTML = new AtomsTable(std::size(kAttributesHTML));
for (uint32_t i = 0; kAttributesHTML[i]; i++) {
sAttributesHTML->Insert(kAttributesHTML[i]);
}
sPresAttributesHTML = new AtomsTable(ArrayLength(kPresAttributesHTML));
sPresAttributesHTML = new AtomsTable(std::size(kPresAttributesHTML));
for (uint32_t i = 0; kPresAttributesHTML[i]; i++) {
sPresAttributesHTML->Insert(kPresAttributesHTML[i]);
}
sElementsSVG = new AtomsTable(ArrayLength(kElementsSVG));
sElementsSVG = new AtomsTable(std::size(kElementsSVG));
for (uint32_t i = 0; kElementsSVG[i]; i++) {
sElementsSVG->Insert(kElementsSVG[i]);
}
sAttributesSVG = new AtomsTable(ArrayLength(kAttributesSVG));
sAttributesSVG = new AtomsTable(std::size(kAttributesSVG));
for (uint32_t i = 0; kAttributesSVG[i]; i++) {
sAttributesSVG->Insert(kAttributesSVG[i]);
}
sElementsMathML = new AtomsTable(ArrayLength(kElementsMathML));
sElementsMathML = new AtomsTable(std::size(kElementsMathML));
for (uint32_t i = 0; kElementsMathML[i]; i++) {
sElementsMathML->Insert(kElementsMathML[i]);
}
sAttributesMathML = new AtomsTable(ArrayLength(kAttributesMathML));
sAttributesMathML = new AtomsTable(std::size(kAttributesMathML));
for (uint32_t i = 0; kAttributesMathML[i]; i++) {
sAttributesMathML->Insert(kAttributesMathML[i]);
}
sBaselineAttributeAllowlist =
new AtomsTable(ArrayLength(kBaselineAttributeAllowlist));
new AtomsTable(std::size(kBaselineAttributeAllowlist));
for (const auto* atom : kBaselineAttributeAllowlist) {
sBaselineAttributeAllowlist->Insert(atom);
}
sBaselineElementAllowlist =
new AtomsTable(ArrayLength(kBaselineElementAllowlist));
new AtomsTable(std::size(kBaselineElementAllowlist));
for (const auto* atom : kBaselineElementAllowlist) {
sBaselineElementAllowlist->Insert(atom);
}
sDefaultConfigurationAttributeAllowlist =
new AtomsTable(ArrayLength(kDefaultConfigurationAttributeAllowlist));
new AtomsTable(std::size(kDefaultConfigurationAttributeAllowlist));
for (const auto* atom : kDefaultConfigurationAttributeAllowlist) {
sDefaultConfigurationAttributeAllowlist->Insert(atom);
}
sDefaultConfigurationElementAllowlist =
new AtomsTable(ArrayLength(kDefaultConfigurationElementAllowlist));
new AtomsTable(std::size(kDefaultConfigurationElementAllowlist));
for (const auto* atom : kDefaultConfigurationElementAllowlist) {
sDefaultConfigurationElementAllowlist->Insert(atom);
}

Просмотреть файл

@ -729,7 +729,7 @@ const char* IncrementUseCounter(UseCounter aUseCounter, bool aIsPage) {
f.write("\n".join(static_asserts))
f.write(
"""\
MOZ_ASSERT(size_t(aUseCounter) < ArrayLength(kEntries));
MOZ_ASSERT(size_t(aUseCounter) < std::size(kEntries));
const auto& entry = kEntries[size_t(aUseCounter)];
(aIsPage ? entry.page_metric : entry.doc_metric).Add();
return entry.name;
@ -771,7 +771,7 @@ const char* IncrementWorkerUseCounter(UseCounterWorker aUseCounter, WorkerKind a
f.write("\n".join(static_asserts))
f.write(
"""\
MOZ_ASSERT(size_t(aUseCounter) < ArrayLength(kEntries));
MOZ_ASSERT(size_t(aUseCounter) < std::size(kEntries));
const auto& entry = kEntries[size_t(aUseCounter)];
switch (aKind) {
case WorkerKind::WorkerKindDedicated:

Просмотреть файл

@ -130,7 +130,7 @@ static const JSErrorFormatString ErrorFormatString[] = {
static const JSErrorFormatString* GetErrorMessage(void* aUserRef,
const unsigned aErrorNumber) {
MOZ_ASSERT(aErrorNumber < ArrayLength(ErrorFormatString));
MOZ_ASSERT(aErrorNumber < std::size(ErrorFormatString));
return &ErrorFormatString[aErrorNumber];
}

Просмотреть файл

@ -482,7 +482,7 @@ class ProtoAndIfaceCache {
JS::Heap<JSObject*>& EntrySlotMustExist(size_t i) { return (*this)[i]; }
void Trace(JSTracer* aTracer) {
for (size_t i = 0; i < ArrayLength(*this); ++i) {
for (size_t i = 0; i < std::size(*this); ++i) {
JS::TraceEdge(aTracer, &(*this)[i], "protoAndIfaceCache[i]");
}
}
@ -497,7 +497,7 @@ class ProtoAndIfaceCache {
PageTableCache() { memset(mPages.begin(), 0, sizeof(mPages)); }
~PageTableCache() {
for (size_t i = 0; i < ArrayLength(mPages); ++i) {
for (size_t i = 0; i < std::size(mPages); ++i) {
delete mPages[i];
}
}
@ -539,10 +539,10 @@ class ProtoAndIfaceCache {
}
void Trace(JSTracer* trc) {
for (size_t i = 0; i < ArrayLength(mPages); ++i) {
for (size_t i = 0; i < std::size(mPages); ++i) {
Page* p = mPages[i];
if (p) {
for (size_t j = 0; j < ArrayLength(*p); ++j) {
for (size_t j = 0; j < std::size(*p); ++j) {
JS::TraceEdge(trc, &(*p)[j], "protoAndIfaceCache[i]");
}
}
@ -551,7 +551,7 @@ class ProtoAndIfaceCache {
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) {
size_t n = aMallocSizeOf(this);
for (size_t i = 0; i < ArrayLength(mPages); ++i) {
for (size_t i = 0; i < std::size(mPages); ++i) {
n += aMallocSizeOf(mPages[i]);
}
return n;
@ -1495,9 +1495,8 @@ inline Maybe<Enum> StringToEnum(const StringT& aString) {
template <typename Enum>
inline constexpr const nsLiteralCString& GetEnumString(Enum stringId) {
MOZ_RELEASE_ASSERT(
static_cast<size_t>(stringId) <
mozilla::ArrayLength(binding_detail::EnumStrings<Enum>::Values));
MOZ_RELEASE_ASSERT(static_cast<size_t>(stringId) <
std::size(binding_detail::EnumStrings<Enum>::Values));
return binding_detail::EnumStrings<Enum>::Values[static_cast<size_t>(
stringId)];
}

Просмотреть файл

@ -6893,7 +6893,7 @@ def getJSToNativeConversionInfo(
defaultCode = fill(
"""
static const char data[] = { ${data} };
$${declName} = JS_NewStringCopyN(cx, data, ArrayLength(data) - 1);
$${declName} = JS_NewStringCopyN(cx, data, std::size(data) - 1);
if (!$${declName}) {
$*{exceptionCode}
}
@ -12434,7 +12434,7 @@ class CGEnumToJSValue(CGAbstractMethod):
def definition_body(self):
return fill(
"""
MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(${strings}));
MOZ_ASSERT(uint32_t(aArgument) < std::size(${strings}));
JSString* resultStr =
JS_NewStringCopyN(aCx, ${strings}[uint32_t(aArgument)].BeginReading(),
${strings}[uint32_t(aArgument)].Length());
@ -12528,7 +12528,7 @@ class CGMaxContiguousEnumValue(CGThing):
static_assert(static_cast<${ty}>(dom::${name}::${minValue}) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(mozilla::ArrayLength(dom::binding_detail::EnumStrings<dom::${name}>::Values) - 1 == UnderlyingValue(value),
static_assert(std::size(dom::binding_detail::EnumStrings<dom::${name}>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
""",

Просмотреть файл

@ -163,12 +163,12 @@ namespace mozilla::dom {
* // Getting offset value from somewhere.
* uint32_t data[3];
* if (!aUint32Array.CopyDataTo(data, [&](const size_t& aLength) {
* if (aLength - offset != ArrayLength(data)) {
* if (aLength - offset != std::size(data)) {
* aError.ThrowTypeError("Typed array doesn't contain the right"
* " amount of data");
* return Maybe<std::pair<size_t, size_t>>();
* }
* return Some(std::make_pair(offset, ArrayLength(data)));
* return Some(std::make_pair(offset, std::size(data)));
* }) {
* return;
* }
@ -213,12 +213,12 @@ namespace mozilla::dom {
* Maybe<Buffer<uint8_t>> buffer =
* aUint8Array.CreateFromData<Buffer<uint8_t>>([&](
* const size_t& aLength) {
* if (aLength - offset != ArrayLength(data)) {
* if (aLength - offset != std::size(data)) {
* aError.ThrowTypeError(
* "Typed array doesn't contain the right amount" of data");
* return Maybe<std::pair<size_t, size_t>>();
* }
* return Some(std::make_pair(offset, ArrayLength(data)));
* return Some(std::make_pair(offset, std::size(data)));
* });
* if (buffer.isNothing()) {
* return;

Просмотреть файл

@ -185,13 +185,13 @@ bool operator!=(StrongGLenum<Details> a, GLenum b) {
#define STRONG_GLENUM_BEGIN(NAME) const uint16_t NAME##Values[] = {
#define STRONG_GLENUM_VALUE(VALUE) LOCAL_GL_##VALUE
#define STRONG_GLENUM_END(NAME) \
} \
; \
struct NAME##Details { \
static size_t valuesCount() { return MOZ_ARRAY_LENGTH(NAME##Values); } \
static const uint16_t* values() { return NAME##Values; } \
}; \
#define STRONG_GLENUM_END(NAME) \
} \
; \
struct NAME##Details { \
static size_t valuesCount() { return std::size(NAME##Values); } \
static const uint16_t* values() { return NAME##Values; } \
}; \
typedef StrongGLenum<NAME##Details> NAME;
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -358,7 +358,7 @@ nsresult CryptoKey::AddPublicKeyData(SECKEYPublicKey* aPublicKey) {
};
mPrivateKey =
PrivateKeyFromPrivateKeyTemplate(keyTemplate, ArrayLength(keyTemplate));
PrivateKeyFromPrivateKeyTemplate(keyTemplate, std::size(keyTemplate));
NS_ENSURE_TRUE(mPrivateKey, NS_ERROR_DOM_OPERATION_ERR);
return NS_OK;
@ -716,7 +716,7 @@ UniqueSECKEYPrivateKey CryptoKey::PrivateKeyFromJwk(const JsonWebKey& aJwk) {
};
return PrivateKeyFromPrivateKeyTemplate(keyTemplate,
ArrayLength(keyTemplate));
std::size(keyTemplate));
}
if (aJwk.mKty.EqualsLiteral(JWK_TYPE_RSA)) {
@ -757,7 +757,7 @@ UniqueSECKEYPrivateKey CryptoKey::PrivateKeyFromJwk(const JsonWebKey& aJwk) {
};
return PrivateKeyFromPrivateKeyTemplate(keyTemplate,
ArrayLength(keyTemplate));
std::size(keyTemplate));
}
if (aJwk.mKty.EqualsLiteral(JWK_TYPE_OKP)) {
@ -823,7 +823,7 @@ UniqueSECKEYPrivateKey CryptoKey::PrivateKeyFromJwk(const JsonWebKey& aJwk) {
};
return PrivateKeyFromPrivateKeyTemplate(keyTemplate,
ArrayLength(keyTemplate));
std::size(keyTemplate));
}
return nullptr;

Просмотреть файл

@ -132,7 +132,7 @@ struct JSStructuredCloneWriter;
static const uint8_t id_ecDH[] = {0x2b, 0x81, 0x04, 0x70};
const SECItem SEC_OID_DATA_EC_DH = {
siBuffer, (unsigned char*)id_ecDH,
static_cast<unsigned int>(mozilla::ArrayLength(id_ecDH))};
static_cast<unsigned int>(std::size(id_ecDH))};
namespace mozilla::dom {

Просмотреть файл

@ -292,7 +292,7 @@ void Clipboard::RequestRead(Promise* aPromise, ReadRequestType aType,
return;
}
AutoTArray<nsCString, ArrayLength(kMandatoryDataTypes)> types;
AutoTArray<nsCString, std::size(kMandatoryDataTypes)> types;
types.AppendElements(Span<const nsLiteralCString>(kMandatoryDataTypes));
callback = MakeRefPtr<ClipboardGetCallbackForRead>(global, std::move(p));

Просмотреть файл

@ -287,7 +287,7 @@ void DataTransfer::SetEffectAllowed(const nsAString& aEffectAllowed) {
static_assert(nsIDragService::DRAGDROP_ACTION_LINK == 4,
"DRAGDROP_ACTION_LINK constant is wrong");
for (uint32_t e = 0; e < ArrayLength(sEffects); e++) {
for (uint32_t e = 0; e < std::size(sEffects); e++) {
if (aEffectAllowed.EqualsASCII(sEffects[e])) {
mEffectAllowed = e;
break;
@ -727,7 +727,7 @@ void DataTransfer::GetExternalClipboardFormats(const bool& aPlainTextOnly,
formats, *mClipboardType, wc, getter_AddRefs(clipboardDataSnapshot));
}
} else {
AutoTArray<nsCString, ArrayLength(kNonPlainTextExternalFormats)> formats;
AutoTArray<nsCString, std::size(kNonPlainTextExternalFormats)> formats;
formats.AppendElements(
Span<const nsLiteralCString>(kNonPlainTextExternalFormats));
if (doContentAnalysis) {
@ -750,7 +750,7 @@ void DataTransfer::GetExternalClipboardFormats(const bool& aPlainTextOnly,
// Order is important for DataTransfer; ensure the returned list items follow
// the sequence specified in kNonPlainTextExternalFormats.
AutoTArray<nsCString, ArrayLength(kNonPlainTextExternalFormats)> flavors;
AutoTArray<nsCString, std::size(kNonPlainTextExternalFormats)> flavors;
clipboardDataSnapshot->GetFlavorList(flavors);
for (const auto& format : kNonPlainTextExternalFormats) {
if (flavors.Contains(format)) {
@ -1443,7 +1443,7 @@ void DataTransfer::CacheExternalDragFormats() {
FillInExternalCustomTypes(c, sysPrincipal);
}
for (uint32_t f = 0; f < ArrayLength(formats); f++) {
for (uint32_t f = 0; f < std::size(formats); f++) {
// IsDataFlavorSupported doesn't take an index as an argument and just
// checks if any of the items support a particular flavor, even though
// the GetData method does take an index. Here, we just assume that

Просмотреть файл

@ -268,7 +268,7 @@ class DataTransfer final : public nsISupports, public nsWrapperCache {
*/
uint32_t DropEffectInt() const { return mDropEffect; }
void SetDropEffectInt(uint32_t aDropEffectInt) {
MOZ_RELEASE_ASSERT(aDropEffectInt < ArrayLength(sEffects),
MOZ_RELEASE_ASSERT(aDropEffectInt < std::size(sEffects),
"Bogus drop effect value");
mDropEffect = aDropEffectInt;
}

Просмотреть файл

@ -94,7 +94,7 @@ void DataTransferItem::SetData(nsIVariant* aData) {
MOZ_ASSERT(!mType.EqualsASCII(kNativeImageMime));
mKind = KIND_STRING;
for (uint32_t i = 0; i < ArrayLength(kFileMimeNameMap); ++i) {
for (uint32_t i = 0; i < std::size(kFileMimeNameMap); ++i) {
if (mType.EqualsASCII(kFileMimeNameMap[i].mMimeName)) {
mKind = KIND_FILE;
break;
@ -406,7 +406,7 @@ already_AddRefed<FileSystemEntry> DataTransferItem::GetAsEntry(
already_AddRefed<File> DataTransferItem::CreateFileFromInputStream(
nsIInputStream* aStream) {
const char* key = nullptr;
for (uint32_t i = 0; i < ArrayLength(kFileMimeNameMap); ++i) {
for (uint32_t i = 0; i < std::size(kFileMimeNameMap); ++i) {
if (mType.EqualsASCII(kFileMimeNameMap[i].mMimeName)) {
key = kFileMimeNameMap[i].mFileName;
break;

Просмотреть файл

@ -487,7 +487,7 @@ int32_t KeyEventHandler::GetMatchingKeyCode(const nsAString& aKeyName) {
uint32_t keyNameLength = keyName.Length();
const char* keyNameStr = keyName.get();
for (unsigned long i = 0; i < ArrayLength(gKeyCodes) - 1; ++i) {
for (unsigned long i = 0; i < std::size(gKeyCodes) - 1; ++i) {
if (keyNameLength == gKeyCodes[i].strlength &&
!nsCRT::strcmp(gKeyCodes[i].str, keyNameStr)) {
return gKeyCodes[i].keycode;

Просмотреть файл

@ -225,7 +225,7 @@ bool UIEvent::Deserialize(IPC::MessageReader* aReader) {
// XXX Following struct and array are used only in
// UIEvent::ComputeModifierState(), but if we define them in it,
// we fail to build on Mac at calling mozilla::ArrayLength().
// we fail to build on Mac at calling std::size().
struct ModifierPair {
Modifier modifier;
const char* name;
@ -263,7 +263,7 @@ Modifiers UIEvent::ComputeModifierState(const nsAString& aModifiersList) {
aModifiersList.BeginReading(listStart);
aModifiersList.EndReading(listEnd);
for (uint32_t i = 0; i < ArrayLength(kPairs); i++) {
for (uint32_t i = 0; i < std::size(kPairs); i++) {
nsAString::const_iterator start(listStart), end(listEnd);
if (!FindInReadable(NS_ConvertASCIItoUTF16(kPairs[i].name), start, end)) {
continue;

Просмотреть файл

@ -270,13 +270,13 @@ already_AddRefed<Promise> GamepadServiceTest::NewPoseMove(
GamepadCapabilityFlags::Cap_LinearAcceleration;
if (!aOrient.IsNull()) {
DebugOnly<bool> ok = aOrient.Value().CopyDataTo(poseState.orientation);
MOZ_ASSERT(
ok, "aOrient.Value().Length() != ArrayLength(poseState.orientation)");
MOZ_ASSERT(ok,
"aOrient.Value().Length() != std::size(poseState.orientation)");
poseState.isOrientationValid = true;
}
if (!aPos.IsNull()) {
DebugOnly<bool> ok = aPos.Value().CopyDataTo(poseState.position);
MOZ_ASSERT(ok, "aPos.Value().Length() != ArrayLength(poseState.position)");
MOZ_ASSERT(ok, "aPos.Value().Length() != std::size(poseState.position)");
poseState.isPositionValid = true;
}
if (!aAngVelocity.IsNull()) {
@ -284,28 +284,28 @@ already_AddRefed<Promise> GamepadServiceTest::NewPoseMove(
aAngVelocity.Value().CopyDataTo(poseState.angularVelocity);
MOZ_ASSERT(ok,
"aAngVelocity.Value().Length() != "
"ArrayLength(poseState.angularVelocity)");
"std::size(poseState.angularVelocity)");
}
if (!aAngAcceleration.IsNull()) {
DebugOnly<bool> ok =
aAngAcceleration.Value().CopyDataTo(poseState.angularAcceleration);
MOZ_ASSERT(ok,
"aAngAcceleration.Value().Length() != "
"ArrayLength(poseState.angularAcceleration)");
"std::size(poseState.angularAcceleration)");
}
if (!aLinVelocity.IsNull()) {
DebugOnly<bool> ok =
aLinVelocity.Value().CopyDataTo(poseState.linearVelocity);
MOZ_ASSERT(ok,
"aLinVelocity.Value().Length() != "
"ArrayLength(poseState.linearVelocity)");
"std::size(poseState.linearVelocity)");
}
if (!aLinAcceleration.IsNull()) {
DebugOnly<bool> ok =
aLinAcceleration.Value().CopyDataTo(poseState.linearAcceleration);
MOZ_ASSERT(ok,
"aLinAcceleration.Value().Length() != "
"ArrayLength(poseState.linearAcceleration)");
"std::size(poseState.linearAcceleration)");
}
GamepadPoseInformation a(poseState);
@ -339,12 +339,12 @@ already_AddRefed<Promise> GamepadServiceTest::NewTouch(
touchState.touchId = aTouchId;
touchState.surfaceId = aSurfaceId;
DebugOnly<bool> ok = aPos.CopyDataTo(touchState.position);
MOZ_ASSERT(ok, "aPos.Length() != ArrayLength(touchState.position)");
MOZ_ASSERT(ok, "aPos.Length() != std::size(touchState.position)");
if (!aSurfDim.IsNull()) {
ok = aSurfDim.Value().CopyDataTo(touchState.surfaceDimensions);
MOZ_ASSERT(
ok, "aSurfDim.Length() != ArrayLength(touchState.surfaceDimensions)");
MOZ_ASSERT(ok,
"aSurfDim.Length() != std::size(touchState.surfaceDimensions)");
touchState.isSurfaceDimensionsValid = true;
}

Просмотреть файл

@ -33,7 +33,7 @@ class udev_lib {
const char* lib_names[] = {"libudev.so.0", "libudev.so.1"};
// Check whether a library is already loaded so we don't load two
// conflicting libs.
for (unsigned i = 0; i < ArrayLength(lib_names); i++) {
for (unsigned i = 0; i < std::size(lib_names); i++) {
lib = dlopen(lib_names[i], RTLD_NOLOAD | RTLD_LAZY | RTLD_GLOBAL);
if (lib) {
break;
@ -42,7 +42,7 @@ class udev_lib {
// If nothing loads the first time through, it means no version of libudev
// was already loaded.
if (!lib) {
for (unsigned i = 0; i < ArrayLength(lib_names); i++) {
for (unsigned i = 0; i < std::size(lib_names); i++) {
lib = dlopen(lib_names[i], RTLD_LAZY | RTLD_GLOBAL);
if (lib) {
break;

Просмотреть файл

@ -31,7 +31,6 @@ namespace {
using namespace mozilla;
using namespace mozilla::dom;
using mozilla::ArrayLength;
// USB HID usage tables, page 1, 0x30 = X
const uint32_t kAxisMinimumUsageNumber = 0x30;
@ -92,7 +91,7 @@ const struct {
{XINPUT_GAMEPAD_B, 1},
{XINPUT_GAMEPAD_X, 2},
{XINPUT_GAMEPAD_Y, 3}};
const size_t kNumMappings = ArrayLength(kXIButtonMap);
const size_t kNumMappings = std::size(kXIButtonMap);
enum GamepadType { kNoGamepad = 0, kRawInputGamepad, kXInputGamepad };
@ -164,7 +163,7 @@ class XInputLoader {
// xinput1_3.dll shipped with the DirectX SDK
const wchar_t* dlls[] = {L"xinput1_4.dll", L"xinput9_1_0.dll",
L"xinput1_3.dll"};
const size_t kNumDLLs = ArrayLength(dlls);
const size_t kNumDLLs = std::size(dlls);
for (size_t i = 0; i < kNumDLLs; ++i) {
module = LoadLibraryW(dlls[i]);
if (module) {
@ -229,7 +228,7 @@ double ScaleAxis(ULONG value, LONG min, LONG max) {
* know how to handle.
*/
bool SupportedUsage(USHORT page, USHORT usage) {
for (unsigned i = 0; i < ArrayLength(kUsagePages); i++) {
for (unsigned i = 0; i < std::size(kUsagePages); i++) {
if (page == kUsagePages[i].usagePage && usage == kUsagePages[i].usage) {
return true;
}
@ -675,7 +674,7 @@ bool WindowsGamepadService::GetRawGamepad(HANDLE handle) {
}
if (gamepad_name.Length() == 0 || !gamepad_name[0]) {
const char kUnknown[] = "Unknown Gamepad";
gamepad_name.SetLength(ArrayLength(kUnknown));
gamepad_name.SetLength(std::size(kUnknown));
strcpy_s(gamepad_name.Elements(), gamepad_name.Length(), kUnknown);
}
@ -987,8 +986,8 @@ void WindowsGamepadService::DevicesChanged(bool aIsStablizing) {
}
bool RegisterRawInput(HWND hwnd, bool enable) {
nsTArray<RAWINPUTDEVICE> rid(ArrayLength(kUsagePages));
rid.SetLength(ArrayLength(kUsagePages));
nsTArray<RAWINPUTDEVICE> rid(std::size(kUsagePages));
rid.SetLength(std::size(kUsagePages));
for (unsigned i = 0; i < rid.Length(); i++) {
rid[i].usUsagePage = kUsagePages[i].usagePage;

Просмотреть файл

@ -178,7 +178,7 @@ static const nsAttrValue::EnumTable kInputTypeTable[] = {
// Default type is 'text'.
static const nsAttrValue::EnumTable* kInputDefaultType =
&kInputTypeTable[ArrayLength(kInputTypeTable) - 2];
&kInputTypeTable[std::size(kInputTypeTable) - 2];
static const nsAttrValue::EnumTable kCaptureTable[] = {
{"user", nsIFilePicker::captureUser},
@ -5418,12 +5418,12 @@ bool HTMLInputElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
FormControlType(kInputDefaultType->value) == FormControlType::InputText,
"Someone forgot to update kInputDefaultType when adding a new "
"input type.");
MOZ_ASSERT(kInputTypeTable[ArrayLength(kInputTypeTable) - 1].tag == nullptr,
MOZ_ASSERT(kInputTypeTable[std::size(kInputTypeTable) - 1].tag == nullptr,
"Last entry in the table must be the nullptr guard");
MOZ_ASSERT(FormControlType(
kInputTypeTable[ArrayLength(kInputTypeTable) - 2].value) ==
FormControlType::InputText,
"Next to last entry in the table must be the \"text\" entry");
MOZ_ASSERT(
FormControlType(kInputTypeTable[std::size(kInputTypeTable) - 2].value) ==
FormControlType::InputText,
"Next to last entry in the table must be the \"text\" entry");
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::type) {

Просмотреть файл

@ -336,7 +336,7 @@ void TextTrackManager::HonorUserPreferencesForTrackSelection() {
// Steps 1 - 3: Perform automatic track selection for different TextTrack
// Kinds.
PerformTrackSelection(ttKinds, ArrayLength(ttKinds));
PerformTrackSelection(ttKinds, std::size(ttKinds));
PerformTrackSelection(TextTrackKind::Descriptions);
PerformTrackSelection(TextTrackKind::Chapters);
@ -363,7 +363,7 @@ bool TextTrackManager::TrackIsDefault(TextTrack* aTextTrack) {
void TextTrackManager::PerformTrackSelection(TextTrackKind aTextTrackKind) {
TextTrackKind ttKinds[] = {aTextTrackKind};
PerformTrackSelection(ttKinds, ArrayLength(ttKinds));
PerformTrackSelection(ttKinds, std::size(ttKinds));
}
void TextTrackManager::PerformTrackSelection(TextTrackKind aTextTrackKinds[],

Просмотреть файл

@ -13234,7 +13234,7 @@ nsresult Maintenance::DirectoryWork() {
PERSISTENCE_TYPE_TEMPORARY, PERSISTENCE_TYPE_PRIVATE};
static_assert(
ArrayLength(kPersistenceTypes) == size_t(PERSISTENCE_TYPE_INVALID),
std::size(kPersistenceTypes) == size_t(PERSISTENCE_TYPE_INVALID),
"Something changed with available persistence types!");
constexpr auto idbDirName =

Просмотреть файл

@ -1598,7 +1598,7 @@ void ContentParent::Init() {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
size_t length = ArrayLength(sObserverTopics);
size_t length = std::size(sObserverTopics);
for (size_t i = 0; i < length; ++i) {
obs->AddObserver(this, sObserverTopics[i], false);
}
@ -1963,7 +1963,7 @@ void ContentParent::ActorDestroy(ActorDestroyReason why) {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
size_t length = ArrayLength(sObserverTopics);
size_t length = std::size(sObserverTopics);
for (size_t i = 0; i < length; ++i) {
obs->RemoveObserver(static_cast<nsIObserver*>(this), sObserverTopics[i]);
}

Просмотреть файл

@ -594,9 +594,9 @@ void MathMLElement::MapGlobalMathMLAttributesInto(
!aBuilder.PropertyIsSet(eCSSProperty_direction)) {
auto str = value->GetStringValue();
static const char dirs[][4] = {"ltr", "rtl"};
static const StyleDirection dirValues[MOZ_ARRAY_LENGTH(dirs)] = {
static const StyleDirection dirValues[std::size(dirs)] = {
StyleDirection::Ltr, StyleDirection::Rtl};
for (uint32_t i = 0; i < ArrayLength(dirs); ++i) {
for (uint32_t i = 0; i < std::size(dirs); ++i) {
if (str.LowerCaseEqualsASCII(dirs[i])) {
aBuilder.SetKeywordValue(eCSSProperty_direction, dirValues[i]);
break;
@ -611,9 +611,9 @@ void MathMLElement::MapGlobalMathMLAttributesInto(
!aBuilder.PropertyIsSet(eCSSProperty_math_style)) {
auto str = value->GetStringValue();
static const char displaystyles[][6] = {"false", "true"};
static const StyleMathStyle mathStyle[MOZ_ARRAY_LENGTH(displaystyles)] = {
static const StyleMathStyle mathStyle[std::size(displaystyles)] = {
StyleMathStyle::Compact, StyleMathStyle::Normal};
for (uint32_t i = 0; i < ArrayLength(displaystyles); ++i) {
for (uint32_t i = 0; i < std::size(displaystyles); ++i) {
if (str.LowerCaseEqualsASCII(displaystyles[i])) {
aBuilder.SetKeywordValue(eCSSProperty_math_style, mathStyle[i]);
break;

Просмотреть файл

@ -162,7 +162,7 @@ class AsyncLogger {
msg->data.mTimestamp = TimeStamp::Now();
msg->data.mDurationUs = 0; // unused, duration is end - begin
StringWriter writer(msg->data.mName, ArrayLength(msg->data.mName));
StringWriter writer(msg->data.mName, std::size(msg->data.mName));
size_t commentIndex;
DebugOnly<bool> truncated = writer.AppendCString(aName, &commentIndex);
@ -188,7 +188,7 @@ class AsyncLogger {
msg->data.mTimestamp = TimeStamp::Now();
msg->data.mDurationUs =
(static_cast<double>(aFrames) / aSampleRate) * 1e6;
size_t len = std::min(strlen(aName), ArrayLength(msg->data.mName));
size_t len = std::min(strlen(aName), std::size(msg->data.mName));
memcpy(msg->data.mName, aName, len);
msg->data.mName[len] = 0;
mMessageQueueProfiler.Push(msg);

Просмотреть файл

@ -1,22 +0,0 @@
/*
* Copyright 2015, Mozilla Foundation and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* 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.
*/
#ifndef __ArrayUtils_h__
#define __ArrayUtils_h__
#define MOZ_ARRAY_LENGTH(array_) (sizeof(array_) / sizeof(array_[0]))
#endif

Просмотреть файл

@ -25,7 +25,6 @@
#include "content_decryption_module.h"
#include "ArrayUtils.h"
#include "ClearKeyUtils.h"
using namespace cdm;

Просмотреть файл

@ -34,7 +34,6 @@
#include "prerror.h"
#include "secmodt.h"
#include "ArrayUtils.h"
#include "BigEndian.h"
#include "ClearKeyBase64.h"
#include "mozilla/Sprintf.h"
@ -259,7 +258,7 @@ static bool EncodeBase64Web(vector<uint8_t> aBinary, string& aEncoded) {
size_t idx = static_cast<size_t>(out[i]);
// out of bounds index for 'sAlphabet'
assert(idx < MOZ_ARRAY_LENGTH(sAlphabet));
assert(idx < std::size(sAlphabet));
out[i] = sAlphabet[idx];
}

Просмотреть файл

@ -3,7 +3,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS += [
"ArrayUtils.h",
"BigEndian.h",
"ClearKeyBase64.h",
"ClearKeyDecryptionManager.h",

Просмотреть файл

@ -118,7 +118,7 @@ bool IsSampleRateSupported(TrackRate aSampleRate) {
AutoTArray<int, 5> supportedSamplingRates;
supportedSamplingRates.AppendElements(
kOpusSupportedInputSamplingRates,
ArrayLength(kOpusSupportedInputSamplingRates));
std::size(kOpusSupportedInputSamplingRates));
return supportedSamplingRates.Contains(aSampleRate);
}

Просмотреть файл

@ -260,8 +260,8 @@ class GMPDiskStorage : public GMPStorage {
int32_t bytesWritten = 0;
char buf[sizeof(uint32_t)] = {0};
LittleEndian::writeUint32(buf, aRecordName.Length());
bytesWritten = PR_Write(record->mFileDesc, buf, MOZ_ARRAY_LENGTH(buf));
if (bytesWritten != MOZ_ARRAY_LENGTH(buf)) {
bytesWritten = PR_Write(record->mFileDesc, buf, std::size(buf));
if (bytesWritten != std::size(buf)) {
NS_WARNING("Failed to write GMPStorage record name length.");
return GMPRecordCorrupted;
}

Просмотреть файл

@ -113,7 +113,7 @@ bool GetRawMachineId(std::vector<uint8_t>* sid_bytes, int* volume_id) {
// Calculate the Windows SID.
wchar_t computer_name[MAX_COMPUTERNAME_LENGTH + 1] = {0};
DWORD size = mozilla::ArrayLength(computer_name);
DWORD size = std::size(computer_name);
if (GetComputerNameW(computer_name, &size)) {
char sid_buffer[SECURITY_MAX_SID_SIZE];

Просмотреть файл

@ -34,14 +34,14 @@ TEST(GeckoMediaPlugins, TestSplitAt)
const char* input = "1,2,3,4";
const char* delims = ",";
const char* tokens[] = {"1", "2", "3", "4"};
TestSplitAt(input, delims, MOZ_ARRAY_LENGTH(tokens), tokens);
TestSplitAt(input, delims, std::size(tokens), tokens);
}
{
const char* input = "a simple, comma, seperated, list";
const char* delims = ",";
const char* tokens[] = {"a simple", " comma", " seperated", " list"};
TestSplitAt(input, delims, MOZ_ARRAY_LENGTH(tokens), tokens);
TestSplitAt(input, delims, std::size(tokens), tokens);
}
{
@ -52,7 +52,7 @@ TEST(GeckoMediaPlugins, TestSplitAt)
"line4";
const char* delims = "\r\n";
const char* tokens[] = {"line1", "line2", "line3", "line4"};
TestSplitAt(input, delims, MOZ_ARRAY_LENGTH(tokens), tokens);
TestSplitAt(input, delims, std::size(tokens), tokens);
}
}

Просмотреть файл

@ -328,7 +328,7 @@ TEST(MP4Demuxer, CENCFragVideo)
nsCString text = ToCryptoString(binding->mSamples[i]->mCrypto);
EXPECT_STREQ(video[i++], text.get());
}
EXPECT_EQ(ArrayLength(video), binding->mSamples.Length());
EXPECT_EQ(std::size(video), binding->mSamples.Length());
binding->mTaskQueue->BeginShutdown();
},
DO_FAIL);
@ -543,7 +543,7 @@ TEST(MP4Demuxer, CENCFragAudio)
nsCString text = ToCryptoString(binding->mSamples[i]->mCrypto);
EXPECT_STREQ(audio[i++], text.get());
}
EXPECT_EQ(ArrayLength(audio), binding->mSamples.Length());
EXPECT_EQ(std::size(audio), binding->mSamples.Length());
binding->mTaskQueue->BeginShutdown();
},
DO_FAIL);

Просмотреть файл

@ -71,7 +71,7 @@ static const TestFileData testFiles[] = {
TEST(libvpx, test_cases)
{
for (size_t test = 0; test < ArrayLength(testFiles); ++test) {
for (size_t test = 0; test < std::size(testFiles); ++test) {
nsTArray<uint8_t> data;
ReadVPXFile(testFiles[test].mFilename, data);
ASSERT_GT(data.Length(), 0u);

Просмотреть файл

@ -44,7 +44,7 @@ TEST(WebMBuffered, BasicTests)
EXPECT_EQ(parser.mCurrentOffset, 0);
unsigned char buf[] = {0x1a, 0x45, 0xdf, 0xa3};
EXPECT_EQ(parser.Append(buf, ArrayLength(buf), mapping), NS_OK);
EXPECT_EQ(parser.Append(buf, std::size(buf), mapping), NS_OK);
EXPECT_TRUE(mapping.IsEmpty());
EXPECT_EQ(parser.mStartOffset, 0);
EXPECT_EQ(parser.mCurrentOffset, 4);

Просмотреть файл

@ -260,7 +260,7 @@ TEST(MP4Metadata, test_case_mp4)
size_t length = 0;
tests = testFiles;
length = ArrayLength(testFiles);
length = std::size(testFiles);
for (size_t test = 0; test < length; ++test) {
nsTArray<uint8_t> buffer = ReadTestFile(tests[test].mFilename);
@ -382,7 +382,7 @@ TEST(MP4Metadata, test_case_mp4)
#if 0
TEST(MP4Metadata, test_case_mp4_subsets) {
static const size_t step = 1u;
for (size_t test = 0; test < ArrayLength(testFiles); ++test) {
for (size_t test = 0; test < std::size(testFiles); ++test) {
nsTArray<uint8_t> buffer = ReadTestFile(testFiles[test].mFilename);
ASSERT_FALSE(buffer.IsEmpty());
ASSERT_LE(step, buffer.Length());
@ -423,7 +423,7 @@ TEST(MoofParser, test_case_mp4)
size_t length = 0;
tests = testFiles;
length = ArrayLength(testFiles);
length = std::size(testFiles);
for (size_t test = 0; test < length; ++test) {
nsTArray<uint8_t> buffer = ReadTestFile(tests[test].mFilename);
@ -469,7 +469,7 @@ TEST(MoofParser, test_case_mp4)
TEST(MoofParser, test_case_sample_description_entries)
{
const TestFileData* tests = testFiles;
size_t length = ArrayLength(testFiles);
size_t length = std::size(testFiles);
for (size_t test = 0; test < length; ++test) {
nsTArray<uint8_t> buffer = ReadTestFile(tests[test].mFilename);
@ -670,7 +670,7 @@ TEST(MoofParser, test_case_moofs_missing_trafs)
#if 0
TEST(MoofParser, test_case_mp4_subsets) {
const size_t step = 1u;
for (size_t test = 0; test < ArrayLength(testFiles); ++test) {
for (size_t test = 0; test < std::size(testFiles); ++test) {
nsTArray<uint8_t> buffer = ReadTestFile(testFiles[test].mFilename);
ASSERT_FALSE(buffer.IsEmpty());
ASSERT_LE(step, buffer.Length());

Просмотреть файл

@ -135,7 +135,7 @@ MediaSessionPlaybackState MediaSession::PlaybackState() const {
void MediaSession::SetActionHandler(MediaSessionAction aAction,
MediaSessionActionHandler* aHandler) {
MOZ_ASSERT(size_t(aAction) < ArrayLength(mActionHandlers));
MOZ_ASSERT(size_t(aAction) < std::size(mActionHandlers));
// If the media session changes its supported action, then we would propagate
// this information to the chrome process in order to run the media session
// actions update algorithm.
@ -151,7 +151,7 @@ void MediaSession::SetActionHandler(MediaSessionAction aAction,
MediaSessionActionHandler* MediaSession::GetActionHandler(
MediaSessionAction aAction) const {
MOZ_ASSERT(size_t(aAction) < ArrayLength(mActionHandlers));
MOZ_ASSERT(size_t(aAction) < std::size(mActionHandlers));
return mActionHandlers[aAction];
}
@ -236,7 +236,7 @@ void MediaSession::DispatchNotifyHandler(
}
bool MediaSession::IsSupportedAction(MediaSessionAction aAction) const {
MOZ_ASSERT(size_t(aAction) < ArrayLength(mActionHandlers));
MOZ_ASSERT(size_t(aAction) < std::size(mActionHandlers));
return mActionHandlers[aAction] != nullptr;
}
@ -284,7 +284,7 @@ void MediaSession::NotifyMediaSessionAttributes() {
if (mMediaMetadata) {
NotifyMetadataUpdated();
}
for (size_t idx = 0; idx < ArrayLength(mActionHandlers); idx++) {
for (size_t idx = 0; idx < std::size(mActionHandlers); idx++) {
MediaSessionAction action = static_cast<MediaSessionAction>(idx);
if (mActionHandlers[action]) {
NotifyEnableSupportedAction(action);

Просмотреть файл

@ -18,7 +18,7 @@ TEST(ContainerParser, MIMETypes)
const char* containerTypes[] = {"video/webm", "audio/webm", "video/mp4",
"audio/mp4", "audio/aac"};
UniquePtr<ContainerParser> parser;
for (size_t i = 0; i < ArrayLength(containerTypes); ++i) {
for (size_t i = 0; i < std::size(containerTypes); ++i) {
Maybe<MediaContainerType> containerType =
MakeMediaContainerType(containerTypes[i]);
ASSERT_TRUE(containerType.isSome());
@ -30,7 +30,7 @@ TEST(ContainerParser, MIMETypes)
already_AddRefed<MediaByteBuffer> make_adts_header() {
const uint8_t test[] = {0xff, 0xf1, 0x50, 0x80, 0x03, 0x1f, 0xfc};
RefPtr<MediaByteBuffer> buffer(new MediaByteBuffer);
buffer->AppendElements(test, ArrayLength(test));
buffer->AppendElements(test, std::size(test));
return buffer.forget();
}

Просмотреть файл

@ -1404,7 +1404,7 @@ bool SkeletonState::DecodeFisbone(ogg_packet* aPacket) {
while (msgLength > 1) {
if (*msgProbe == '\r' && *(msgProbe + 1) == '\n') {
nsAutoCString strMsg(msgHead, msgProbe - msgHead);
for (size_t i = 0; i < ArrayLength(kFieldTypeMaps); i++) {
for (size_t i = 0; i < std::size(kFieldTypeMaps); i++) {
if (strMsg.Find(kFieldTypeMaps[i].mPatternToRecognize) != -1) {
// The content of message header fields follows [RFC2822], and the
// mandatory message field must be encoded in US-ASCII, others

Просмотреть файл

@ -69,7 +69,7 @@ bool ConvertSample(uint16_t aChannelCount, uint8_t aFrequencyIndex,
header[6] = 0xfc;
UniquePtr<MediaRawDataWriter> writer(aSample->CreateWriter());
if (!writer->Prepend(&header[0], ArrayLength(header))) {
if (!writer->Prepend(&header[0], std::size(header))) {
return false;
}
@ -176,7 +176,7 @@ bool FrameHeader::Parse(const Span<const uint8_t>& aData) {
static const uint32_t SAMPLE_RATES[] = {96000, 88200, 64000, 48000, 44100,
32000, 24000, 22050, 16000, 12000,
11025, 8000, 7350};
if (mSamplingIndex >= ArrayLength(SAMPLE_RATES)) {
if (mSamplingIndex >= std::size(SAMPLE_RATES)) {
LOG(("ADTS: Init() failure: invalid sample-rate index value: %" PRIu32 ".",
mSamplingIndex));
// This marks the header as invalid.

Просмотреть файл

@ -50,7 +50,7 @@ Result<Ok, nsresult> AnnexB::ConvertAVCCSampleToAnnexB(
MOZ_TRY_VAR(nalLen, reader.ReadU32());
const uint8_t* p = reader.Read(nalLen);
if (!writer.Write(kAnnexBDelimiter, ArrayLength(kAnnexBDelimiter))) {
if (!writer.Write(kAnnexBDelimiter, std::size(kAnnexBDelimiter))) {
return Err(NS_ERROR_OUT_OF_MEMORY);
}
if (!p) {
@ -122,7 +122,7 @@ Result<Ok, nsresult> AnnexB::ConvertHVCCSampleToAnnexB(
uint32_t nalLen;
MOZ_TRY_VAR(nalLen, reader.ReadU32());
const uint8_t* p = reader.Read(nalLen);
if (!writer.Write(kAnnexBDelimiter, ArrayLength(kAnnexBDelimiter))) {
if (!writer.Write(kAnnexBDelimiter, std::size(kAnnexBDelimiter))) {
LOG("Failed to write kAnnexBDelimiter, OOM?");
return Err(NS_ERROR_OUT_OF_MEMORY);
}
@ -218,7 +218,7 @@ already_AddRefed<mozilla::MediaByteBuffer> AnnexB::ConvertHVCCExtraDataToAnnexB(
const HVCCConfig hvcc = rv.unwrap();
RefPtr<mozilla::MediaByteBuffer> annexB = new mozilla::MediaByteBuffer;
for (const auto& nalu : hvcc.mNALUs) {
annexB->AppendElements(kAnnexBDelimiter, ArrayLength(kAnnexBDelimiter));
annexB->AppendElements(kAnnexBDelimiter, std::size(kAnnexBDelimiter));
annexB->AppendElements(nalu.mNALU.Elements(), nalu.mNALU.Length());
LOGV("Insert NALU (type=%hhu, size=%zu) to AnnexB (size=%zu)",
nalu.mNalUnitType, nalu.mNALU.Length(), annexB->Length());
@ -236,7 +236,7 @@ Result<mozilla::Ok, nsresult> AnnexB::ConvertSPSOrPPS(
if (!ptr) {
return Err(NS_ERROR_FAILURE);
}
aAnnexB->AppendElements(kAnnexBDelimiter, ArrayLength(kAnnexBDelimiter));
aAnnexB->AppendElements(kAnnexBDelimiter, std::size(kAnnexBDelimiter));
aAnnexB->AppendElements(ptr, length);
}
return Ok();
@ -404,7 +404,7 @@ bool AnnexB::ConvertSampleToAVCC(mozilla::MediaRawData* aSample,
};
// XXX(Bug 1631371) Check if this should use a fallible operation as it
// pretended earlier.
extradata->AppendElements(kFakeExtraData, ArrayLength(kFakeExtraData));
extradata->AppendElements(kFakeExtraData, std::size(kFakeExtraData));
aSample->mExtraData = std::move(extradata);
return true;
}

Просмотреть файл

@ -118,7 +118,7 @@ static already_AddRefed<MediaRawData> GetHVCCSample(uint32_t aSampleSize) {
EXPECT_FALSE(true) << "Samples should be requested with sane sizes";
}
auto extradata = MakeRefPtr<mozilla::MediaByteBuffer>();
extradata->AppendElements(sHvccBytesBuffer, ArrayLength(sHvccBytesBuffer));
extradata->AppendElements(sHvccBytesBuffer, std::size(sHvccBytesBuffer));
// Write the NAL size.
nsTArray<uint8_t> sampleData;
@ -145,7 +145,7 @@ static already_AddRefed<MediaRawData> GetHVCCSample(
EXPECT_FALSE(true) << "Samples should be requested with sane sizes";
}
auto extradata = MakeRefPtr<mozilla::MediaByteBuffer>();
extradata->AppendElements(sHvccBytesBuffer, ArrayLength(sHvccBytesBuffer));
extradata->AppendElements(sHvccBytesBuffer, std::size(sHvccBytesBuffer));
// Write the NAL size.
nsTArray<uint8_t> sampleData;
@ -346,7 +346,7 @@ TEST(H264, AVCCParsingSuccess)
0xe0 /* num SPS (0) */,
0 /* num PPS (0) */
};
extradata->AppendElements(avccBytesBuffer, ArrayLength(avccBytesBuffer));
extradata->AppendElements(avccBytesBuffer, std::size(avccBytesBuffer));
auto rv = AVCCConfig::Parse(extradata);
EXPECT_TRUE(rv.isOk());
const auto avcc = rv.unwrap();
@ -372,7 +372,7 @@ TEST(H264, AVCCParsingFailure)
0xe0 /* num SPS (0) */,
0 /* num PPS (0) */
};
extradata->AppendElements(avccBytesBuffer, ArrayLength(avccBytesBuffer));
extradata->AppendElements(avccBytesBuffer, std::size(avccBytesBuffer));
auto avcc = AVCCConfig::Parse(extradata);
EXPECT_TRUE(avcc.isErr());
}
@ -387,7 +387,7 @@ TEST(H264, AVCCParsingFailure)
0xfc | 3 /* nal size - 1 */,
0xe0 /* num SPS (0) */,
};
extradata->AppendElements(avccBytesBuffer, ArrayLength(avccBytesBuffer));
extradata->AppendElements(avccBytesBuffer, std::size(avccBytesBuffer));
auto avcc = AVCCConfig::Parse(extradata);
EXPECT_TRUE(avcc.isErr());
}
@ -424,7 +424,7 @@ TEST(H265, HVCCParsingSuccess)
,
0 /* numOfArrays */,
};
extradata->AppendElements(hvccBytesBuffer, ArrayLength(hvccBytesBuffer));
extradata->AppendElements(hvccBytesBuffer, std::size(hvccBytesBuffer));
auto rv = HVCCConfig::Parse(extradata);
EXPECT_TRUE(rv.isOk());
auto hvcc = rv.unwrap();
@ -513,7 +513,7 @@ TEST(H265, HVCCParsingSuccess)
0 /* NALU header 2/2 */,
0 /* rbsp */,
};
extradata->AppendElements(hvccBytesBuffer, ArrayLength(hvccBytesBuffer));
extradata->AppendElements(hvccBytesBuffer, std::size(hvccBytesBuffer));
auto rv = HVCCConfig::Parse(extradata);
EXPECT_TRUE(rv.isOk());
auto hvcc = rv.unwrap();
@ -571,7 +571,7 @@ TEST(H265, HVCCParsingFailure)
,
0 /* numOfArrays */,
};
extradata->AppendElements(hvccBytesBuffer, ArrayLength(hvccBytesBuffer));
extradata->AppendElements(hvccBytesBuffer, std::size(hvccBytesBuffer));
auto avcc = HVCCConfig::Parse(extradata);
EXPECT_TRUE(avcc.isErr());
}
@ -593,7 +593,7 @@ TEST(H265, HVCCParsingFailure)
0 /* general_constraint_indicator_flags 6/6 */,
0x5A /* general_level_idc */
};
extradata->AppendElements(hvccBytesBuffer, ArrayLength(hvccBytesBuffer));
extradata->AppendElements(hvccBytesBuffer, std::size(hvccBytesBuffer));
auto avcc = HVCCConfig::Parse(extradata);
EXPECT_TRUE(avcc.isErr());
}
@ -652,7 +652,7 @@ TEST(H265, HVCCToAnnexB)
0 /* NALU header 2/2 */,
0 /* rbsp */,
};
extradata->AppendElements(hvccBytesBuffer, ArrayLength(hvccBytesBuffer));
extradata->AppendElements(hvccBytesBuffer, std::size(hvccBytesBuffer));
// We convert hvcc extra-data to annexb format, then parse each nalu to see if
// they are still correct or not.
@ -709,7 +709,7 @@ static const uint8_t sSps[] = {
TEST(H265, ExtractHVCCExtraData)
{
RefPtr<MediaRawData> rawData{GetHVCCSample(sSps, ArrayLength(sSps))};
RefPtr<MediaRawData> rawData{GetHVCCSample(sSps, std::size(sSps))};
RefPtr<MediaByteBuffer> extradata = H265::ExtractHVCCExtraData(rawData);
EXPECT_TRUE(extradata);
auto rv = HVCCConfig::Parse(extradata);
@ -725,7 +725,7 @@ TEST(H265, ExtractHVCCExtraData)
TEST(H265, DecodeSPSFromSPSNALU)
{
H265NALU nalu{sSps, ArrayLength(sSps)};
H265NALU nalu{sSps, std::size(sSps)};
auto rv = H265::DecodeSPSFromSPSNALU(nalu);
EXPECT_TRUE(rv.isOk());
auto sps = rv.unwrap();

Просмотреть файл

@ -666,11 +666,11 @@ CFDictionaryRef AppleVTDecoder::CreateDecoderExtensions() {
: CFSTR("av1C");
;
const void* atomsValue[] = {data};
static_assert(ArrayLength(atomsKey) == ArrayLength(atomsValue),
static_assert(std::size(atomsKey) == std::size(atomsValue),
"Non matching keys/values array size");
AutoCFRelease<CFDictionaryRef> atoms = CFDictionaryCreate(
kCFAllocatorDefault, atomsKey, atomsValue, ArrayLength(atomsKey),
kCFAllocatorDefault, atomsKey, atomsValue, std::size(atomsKey),
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
const void* extensionKeys[] = {
@ -680,11 +680,11 @@ CFDictionaryRef AppleVTDecoder::CreateDecoderExtensions() {
const void* extensionValues[] = {kCVImageBufferChromaLocation_Left,
kCVImageBufferChromaLocation_Left, atoms};
static_assert(ArrayLength(extensionKeys) == ArrayLength(extensionValues),
static_assert(std::size(extensionKeys) == std::size(extensionValues),
"Non matching keys/values array size");
return CFDictionaryCreate(kCFAllocatorDefault, extensionKeys, extensionValues,
ArrayLength(extensionKeys),
std::size(extensionKeys),
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
}
@ -699,12 +699,12 @@ CFDictionaryRef AppleVTDecoder::CreateDecoderSpecification() {
// This GPU is blacklisted for hardware decoding.
specValues[0] = kCFBooleanFalse;
}
static_assert(ArrayLength(specKeys) == ArrayLength(specValues),
static_assert(std::size(specKeys) == std::size(specValues),
"Non matching keys/values array size");
return CFDictionaryCreate(
kCFAllocatorDefault, specKeys, specValues, ArrayLength(specKeys),
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
return CFDictionaryCreate(kCFAllocatorDefault, specKeys, specValues,
std::size(specKeys), &kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
}
CFDictionaryRef AppleVTDecoder::CreateOutputConfiguration() {
@ -715,11 +715,11 @@ CFDictionaryRef AppleVTDecoder::CreateOutputConfiguration() {
kCFAllocatorDefault, kCFNumberSInt32Type, &PixelFormatTypeValue);
const void* outputKeys[] = {kCVPixelBufferPixelFormatTypeKey};
const void* outputValues[] = {PixelFormatTypeNumber};
static_assert(ArrayLength(outputKeys) == ArrayLength(outputValues),
static_assert(std::size(outputKeys) == std::size(outputValues),
"Non matching keys/values array size");
return CFDictionaryCreate(
kCFAllocatorDefault, outputKeys, outputValues, ArrayLength(outputKeys),
kCFAllocatorDefault, outputKeys, outputValues, std::size(outputKeys),
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
}
@ -737,13 +737,13 @@ CFDictionaryRef AppleVTDecoder::CreateOutputConfiguration() {
// Construct IOSurface Properties
const void* IOSurfaceKeys[] = {kIOSurfaceIsGlobal};
const void* IOSurfaceValues[] = {kCFBooleanTrue};
static_assert(ArrayLength(IOSurfaceKeys) == ArrayLength(IOSurfaceValues),
static_assert(std::size(IOSurfaceKeys) == std::size(IOSurfaceValues),
"Non matching keys/values array size");
// Contruct output configuration.
AutoCFRelease<CFDictionaryRef> IOSurfaceProperties = CFDictionaryCreate(
kCFAllocatorDefault, IOSurfaceKeys, IOSurfaceValues,
ArrayLength(IOSurfaceKeys), &kCFTypeDictionaryKeyCallBacks,
std::size(IOSurfaceKeys), &kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
const void* outputKeys[] = {kCVPixelBufferIOSurfacePropertiesKey,
@ -751,11 +751,11 @@ CFDictionaryRef AppleVTDecoder::CreateOutputConfiguration() {
kCVPixelBufferOpenGLCompatibilityKey};
const void* outputValues[] = {IOSurfaceProperties, PixelFormatTypeNumber,
kCFBooleanTrue};
static_assert(ArrayLength(outputKeys) == ArrayLength(outputValues),
static_assert(std::size(outputKeys) == std::size(outputValues),
"Non matching keys/values array size");
return CFDictionaryCreate(
kCFAllocatorDefault, outputKeys, outputValues, ArrayLength(outputKeys),
kCFAllocatorDefault, outputKeys, outputValues, std::size(outputKeys),
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
}

Просмотреть файл

@ -41,11 +41,11 @@ static CFDictionaryRef BuildEncoderSpec(const bool aHardwareNotAllowed,
kVTVideoEncoderSpecification_EnableLowLatencyRateControl};
const void* values[] = {kCFBooleanTrue, kCFBooleanTrue};
static_assert(ArrayLength(keys) == ArrayLength(values),
static_assert(std::size(keys) == std::size(values),
"Non matching keys/values array size");
return CFDictionaryCreate(
kCFAllocatorDefault, keys, values, ArrayLength(keys),
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
return CFDictionaryCreate(kCFAllocatorDefault, keys, values,
std::size(keys), &kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
}
}
const void* keys[] = {
@ -53,10 +53,10 @@ static CFDictionaryRef BuildEncoderSpec(const bool aHardwareNotAllowed,
const void* values[] = {aHardwareNotAllowed ? kCFBooleanFalse
: kCFBooleanTrue};
static_assert(ArrayLength(keys) == ArrayLength(values),
static_assert(std::size(keys) == std::size(values),
"Non matching keys/values array size");
return CFDictionaryCreate(kCFAllocatorDefault, keys, values,
ArrayLength(keys), &kCFTypeDictionaryKeyCallBacks,
return CFDictionaryCreate(kCFAllocatorDefault, keys, values, std::size(keys),
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
}
@ -360,11 +360,11 @@ CFDictionaryRef AppleVTEncoder::BuildSourceImageBufferAttributes() {
CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &fmt));
const void* values[] = {kCFBooleanTrue, ioSurfaceProps, pixelFormat};
MOZ_ASSERT(ArrayLength(keys) == ArrayLength(values),
MOZ_ASSERT(std::size(keys) == std::size(values),
"Non matching keys/values array size");
return CFDictionaryCreate(kCFAllocatorDefault, keys, values,
ArrayLength(keys), &kCFTypeDictionaryKeyCallBacks,
return CFDictionaryCreate(kCFAllocatorDefault, keys, values, std::size(keys),
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
}
@ -636,9 +636,9 @@ RefPtr<MediaDataEncoder::EncodePromise> AppleVTEncoder::ProcessEncode(
if (aSample->mKeyframe) {
CFTypeRef keys[] = {kVTEncodeFrameOptionKey_ForceKeyFrame};
CFTypeRef values[] = {kCFBooleanTrue};
MOZ_ASSERT(ArrayLength(keys) == ArrayLength(values));
MOZ_ASSERT(std::size(keys) == std::size(values));
frameProps = CFDictionaryCreate(
kCFAllocatorDefault, keys, values, ArrayLength(keys),
kCFAllocatorDefault, keys, values, std::size(keys),
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
};

Просмотреть файл

@ -76,7 +76,7 @@ bool FFmpegRuntimeLinker::Init() {
// more precise error if possible.
sLinkStatus = LinkStatus_NOT_FOUND;
for (size_t i = 0; i < ArrayLength(sLibs); i++) {
for (size_t i = 0; i < std::size(sLibs); i++) {
const char* lib = sLibs[i];
PRLibSpec lspec;
lspec.type = PR_LibSpec_Pathname;
@ -139,7 +139,7 @@ bool FFmpegRuntimeLinker::Init() {
}
FFMPEGV_LOG("H264/AAC codecs unsupported without [");
for (size_t i = 0; i < ArrayLength(sLibs); i++) {
for (size_t i = 0; i < std::size(sLibs); i++) {
FFMPEGV_LOG("%s %s", i ? "," : " ", sLibs[i]);
}
FFMPEGV_LOG(" ]\n");

Просмотреть файл

@ -74,7 +74,7 @@ bool OmxCoreLibLinker::Link() {
}
// try known paths
for (size_t i = 0; i < ArrayLength(sLibNames); i++) {
for (size_t i = 0; i < std::size(sLibNames); i++) {
if (TryLinkingLibrary(sLibNames[i])) {
sLinkStatus = LinkStatus_SUCCEEDED;
return true;

Просмотреть файл

@ -130,7 +130,7 @@ void DelayBuffer::ReadChannels(const float aPerFrameDelays[WEBAUDIO_BLOCK_SIZE],
positions[1] = PositionForDelay(floorDelay) + i;
positions[0] = positions[1] - 1;
for (unsigned tick = 0; tick < ArrayLength(positions); ++tick) {
for (unsigned tick = 0; tick < std::size(positions); ++tick) {
int readChunk = ChunkForPosition(positions[tick]);
// The zero check on interpolationFactor is important because, when
// currentDelay is integer, positions[0] may be outside the range

Просмотреть файл

@ -40,7 +40,7 @@ namespace WebCore {
const int elevationSpacing = irc_composite_c_r0195_elevation_interval;
const int firstElevation = irc_composite_c_r0195_first_elevation;
const int numberOfElevations = MOZ_ARRAY_LENGTH(irc_composite_c_r0195);
const int numberOfElevations = std::size(irc_composite_c_r0195);
const unsigned HRTFElevation::NumberOfTotalAzimuths = 360 / 15 * 8;

Просмотреть файл

@ -20,8 +20,6 @@
#include "mozilla/ArrayUtils.h"
using mozilla::ArrayLength;
const int16_t irc_composite_c_r0195_p315[][256] =
{/* IRC_Composite_C_R0195_T000_P315.wav */
{-37, 37, -38, 39, -39, 40, -41, 42, -42, 43, -43,
@ -4555,16 +4553,16 @@ struct Elevation {
* elevation.
*/
const Elevation irc_composite_c_r0195[] = {
{irc_composite_c_r0195_p315, MOZ_ARRAY_LENGTH(irc_composite_c_r0195_p315)},
{irc_composite_c_r0195_p330, MOZ_ARRAY_LENGTH(irc_composite_c_r0195_p330)},
{irc_composite_c_r0195_p345, MOZ_ARRAY_LENGTH(irc_composite_c_r0195_p345)},
{irc_composite_c_r0195_p000, MOZ_ARRAY_LENGTH(irc_composite_c_r0195_p000)},
{irc_composite_c_r0195_p015, MOZ_ARRAY_LENGTH(irc_composite_c_r0195_p015)},
{irc_composite_c_r0195_p030, MOZ_ARRAY_LENGTH(irc_composite_c_r0195_p030)},
{irc_composite_c_r0195_p045, MOZ_ARRAY_LENGTH(irc_composite_c_r0195_p045)},
{irc_composite_c_r0195_p060, MOZ_ARRAY_LENGTH(irc_composite_c_r0195_p060)},
{irc_composite_c_r0195_p075, MOZ_ARRAY_LENGTH(irc_composite_c_r0195_p075)},
{irc_composite_c_r0195_p090, MOZ_ARRAY_LENGTH(irc_composite_c_r0195_p090)}};
{irc_composite_c_r0195_p315, std::size(irc_composite_c_r0195_p315)},
{irc_composite_c_r0195_p330, std::size(irc_composite_c_r0195_p330)},
{irc_composite_c_r0195_p345, std::size(irc_composite_c_r0195_p345)},
{irc_composite_c_r0195_p000, std::size(irc_composite_c_r0195_p000)},
{irc_composite_c_r0195_p015, std::size(irc_composite_c_r0195_p015)},
{irc_composite_c_r0195_p030, std::size(irc_composite_c_r0195_p030)},
{irc_composite_c_r0195_p045, std::size(irc_composite_c_r0195_p045)},
{irc_composite_c_r0195_p060, std::size(irc_composite_c_r0195_p060)},
{irc_composite_c_r0195_p075, std::size(irc_composite_c_r0195_p075)},
{irc_composite_c_r0195_p090, std::size(irc_composite_c_r0195_p090)}};
const int irc_composite_c_r0195_first_elevation = -45; /* degrees */
const int irc_composite_c_r0195_elevation_interval = 15; /* degrees */

Просмотреть файл

@ -136,7 +136,7 @@ ReverbConvolver::ReverbConvolver(const float* impulseResponseData,
// performed in blocks 3 + 8 * n and size 1024 at 1 + 4 * n.
const uint32_t phaseLookup[] = {14, 0, 10, 4};
stagePhase = WEBAUDIO_BLOCK_SIZE *
phaseLookup[m_stages.Length() % ArrayLength(phaseLookup)];
phaseLookup[m_stages.Length() % std::size(phaseLookup)];
} else if (fftSize > maxFFTSize) {
fftSize = maxFFTSize;
// A prime offset spreads out FFTs in a way that all

Просмотреть файл

@ -598,7 +598,7 @@ bool TransportLayerDtls::Setup() {
}
rv = SSL_NamedGroupConfig(ssl_fd.get(), NamedGroupPreferences,
mozilla::ArrayLength(NamedGroupPreferences));
std::size(NamedGroupPreferences));
if (rv != SECSuccess) {
MOZ_MTLOG(ML_ERROR, "Couldn't set named groups");
return false;

Просмотреть файл

@ -1131,7 +1131,7 @@ const char* SpeechRecognition::GetName(FSMState aId) {
};
MOZ_ASSERT(aId < STATE_COUNT);
MOZ_ASSERT(ArrayLength(names) == STATE_COUNT);
MOZ_ASSERT(std::size(names) == STATE_COUNT);
return names[aId];
}
@ -1146,7 +1146,7 @@ const char* SpeechRecognition::GetName(SpeechEvent* aEvent) {
"EVENT_RECOGNITIONSERVICE_ERROR"};
MOZ_ASSERT(aEvent->mType < EVENT_COUNT);
MOZ_ASSERT(ArrayLength(names) == EVENT_COUNT);
MOZ_ASSERT(std::size(names) == EVENT_COUNT);
return names[aEvent->mType];
}

Просмотреть файл

@ -334,7 +334,7 @@ void SpeechDispatcherService::Setup() {
return;
}
for (uint32_t i = 0; i < ArrayLength(kSpeechDispatcherSymbols); i++) {
for (uint32_t i = 0; i < std::size(kSpeechDispatcherSymbols); i++) {
*kSpeechDispatcherSymbols[i].function = PR_FindFunctionSymbol(
speechdLib, kSpeechDispatcherSymbols[i].functionName);

Просмотреть файл

@ -240,7 +240,7 @@ static void AddVoices(nsISpeechService* aService, const VoiceDetails* aVoices,
void nsFakeSynthServices::Init() {
mSynthService = new FakeSpeechSynth();
AddVoices(mSynthService, sVoices, ArrayLength(sVoices));
AddVoices(mSynthService, sVoices, std::size(sVoices));
}
// nsIObserver

Просмотреть файл

@ -86,7 +86,7 @@ bool IsValidMessage(const MIDIMessage* aMsg) {
// much about message validity other than that.
if ((cmd & kSystemMessage) == kSystemMessage) {
if (cmd - kSystemMessage >=
static_cast<uint8_t>(ArrayLength(kSystemLengths))) {
static_cast<uint8_t>(std::size(kSystemLengths))) {
NS_WARNING("System Message Command byte not valid!");
return false;
}
@ -96,7 +96,7 @@ bool IsValidMessage(const MIDIMessage* aMsg) {
// of the first byte. Shift this down to give the index of the expected packet
// length.
uint8_t cmdIndex = (cmd - kCommandByte) >> 4;
if (cmdIndex >= ArrayLength(kCommandLengths)) {
if (cmdIndex >= std::size(kCommandLengths)) {
// If our index is bigger than our array length, command byte is unknown;
NS_WARNING("Unknown MIDI command!");
return false;

Просмотреть файл

@ -29,11 +29,11 @@ static const nsLiteralCString kPermissionTypes[] = {
const size_t kPermissionNameCount = ContiguousEnumSize<PermissionName>::value;
static_assert(MOZ_ARRAY_LENGTH(kPermissionTypes) == kPermissionNameCount,
static_assert(std::size(kPermissionTypes) == kPermissionNameCount,
"kPermissionTypes and PermissionName count should match");
const nsLiteralCString& PermissionNameToType(PermissionName aName) {
MOZ_ASSERT((size_t)aName < ArrayLength(kPermissionTypes));
MOZ_ASSERT((size_t)aName < std::size(kPermissionTypes));
return kPermissionTypes[static_cast<size_t>(aName)];
}
@ -50,7 +50,7 @@ Maybe<PermissionName> TypeToPermissionName(const nsACString& aType) {
return Some(PermissionName::Storage_access);
}
for (size_t i = 0; i < ArrayLength(kPermissionTypes); ++i) {
for (size_t i = 0; i < std::size(kPermissionTypes); ++i) {
if (kPermissionTypes[i].Equals(aType)) {
return Some(static_cast<PermissionName>(i));
}

Просмотреть файл

@ -367,7 +367,7 @@ FilenameTypeAndDetails nsContentSecurityUtils::FilenameToFilenameType(
? kMozillaExtensionFile
: kOtherExtensionFile;
const auto& extensionNameAndPath =
Substring(regexResults[0], ArrayLength("extensions/") - 1);
Substring(regexResults[0], std::size("extensions/") - 1);
return FilenameTypeAndDetails(
type, Some(OptimizeFileName(extensionNameAndPath)));
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше