mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 04:38:02 +00:00
Bug 1483449 - Simplify nsStaticAtomUtils::Lookup. r=njn
This commit is contained in:
parent
061be62bb5
commit
0e70842906
@ -13,15 +13,17 @@
|
||||
#include "mozilla/Maybe.h"
|
||||
|
||||
// This class holds basic operations on arrays of static atoms.
|
||||
class nsStaticAtomUtils {
|
||||
class nsStaticAtomUtils
|
||||
{
|
||||
public:
|
||||
static mozilla::Maybe<uint32_t> Lookup(nsAtom* aAtom,
|
||||
const nsStaticAtom* aAtoms,
|
||||
uint32_t aCount)
|
||||
{
|
||||
for (uint32_t i = 0; i < aCount; i++) {
|
||||
if (aAtom == &aAtoms[i]) {
|
||||
return mozilla::Some(i);
|
||||
if (aAtom->IsStatic()) {
|
||||
ptrdiff_t index = aAtom->AsStatic() - aAtoms;
|
||||
if (index >= 0 && index < static_cast<ptrdiff_t>(aCount)) {
|
||||
return mozilla::Some(static_cast<uint32_t>(index));
|
||||
}
|
||||
}
|
||||
return mozilla::Nothing();
|
||||
|
Loading…
x
Reference in New Issue
Block a user