Bug 639469 - Use mozilla::ArrayLength and mozilla::ArrayEnd in preference to JS_ARRAY_LENGTH whenever possible. r=cjones

This commit is contained in:
Jeff Walden
2011-10-10 23:00:28 -07:00
parent 946f2ae0e3
commit 9dc00cdc62
30 changed files with 177 additions and 92 deletions

View File

@@ -44,6 +44,7 @@
#include <string.h>
#include "mozilla/RangedPtr.h"
#include "mozilla/Util.h"
#include "jstypes.h"
#include "jsstdint.h"
@@ -68,6 +69,7 @@
#include "vm/String-inl.h"
using namespace mozilla;
using namespace js;
using namespace js::gc;
@@ -363,7 +365,7 @@ js_InitCommonAtoms(JSContext *cx)
{
JSAtomState *state = &cx->runtime->atomState;
JSAtom **atoms = state->commonAtomsStart();
for (size_t i = 0; i < JS_ARRAY_LENGTH(js_common_atom_names); i++, atoms++) {
for (size_t i = 0; i < ArrayLength(js_common_atom_names); i++, atoms++) {
JSAtom *atom = js_Atomize(cx, js_common_atom_names[i], strlen(js_common_atom_names[i]),
InternAtom);
if (!atom)
@@ -677,7 +679,7 @@ IndexToIdSlow(JSContext *cx, uint32 index, jsid *idp)
JS_ASSERT(index > JSID_INT_MAX);
jschar buf[UINT32_CHAR_BUFFER_LENGTH];
RangedPtr<jschar> end(buf + JS_ARRAY_LENGTH(buf), buf, buf + JS_ARRAY_LENGTH(buf));
RangedPtr<jschar> end(buf + ArrayLength(buf), buf, buf + ArrayLength(buf));
RangedPtr<jschar> start = BackfillIndexInCharBuffer(index, end);
JSAtom *atom = js_AtomizeChars(cx, start.get(), end - start);