Closed Bug 1483449 Opened 6 years ago Closed 6 years ago

simplify nsStaticAtomUtils::Lookup

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: heycam, Assigned: heycam)

References

Details

Attachments

(1 file)

After bug 1482782, nsStaticAtomUtils::Lookup can become simpler since we know at compile time what the index of the input atom is in the static atom table.
Attached file patch
Assignee: nobody → cam
Status: NEW → ASSIGNED
Attachment #9001451 - Flags: review?(n.nethercote)
Comment on attachment 9001451 [details]
patch

Thank you for doing this.

> +      ptrdiff_t index = static_cast<nsStaticAtom*>(aAtom) - aAtoms;

Use aAtom->AsStatic()?

> +      if (index >= 0 && index < aCount) {

I find these easier to read like this:

> +      if (0 <= index && index < aCount) {
Attachment #9001451 - Flags: review?(n.nethercote) → review+
Pushed by cmccormack@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/a91ccbe2b3fd
Simplify nsStaticAtomUtils::Lookup. r=njn
Backed out for failures at nsStaticAtomUtils.h:25

backout: https://hg.mozilla.org/integration/mozilla-inbound/rev/280d5dade1c6296b232fcf876a1ece7a8cf79784

push with failures: https://treeherder.mozilla.org/#/jobs?repo=mozilla-inbound&revision=a91ccbe2b3fd8b9303b034d7a6035de572495fd0&group_state=expanded&selectedJob=194219522

failure log: https://treeherder.mozilla.org/logviewer.html#?job_id=194219522&repo=mozilla-inbound&lineNumber=25139

task 2018-08-16T01:55:39.060Z] 01:55:39     INFO -  In file included from /builds/worker/workspace/build/src/layout/style/nsCSSAnonBoxes.cpp:13:0:
[task 2018-08-16T01:55:39.060Z] 01:55:39     INFO -  /builds/worker/workspace/build/src/obj-firefox/dist/include/nsStaticAtomUtils.h: In static member function 'static mozilla::Maybe<unsigned int> nsStaticAtomUtils::Lookup(nsAtom*, const nsStaticAtom*, uint32_t)':
[task 2018-08-16T01:55:39.060Z] 01:55:39     INFO -  /builds/worker/workspace/build/src/obj-firefox/dist/include/nsStaticAtomUtils.h:25:31: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
[task 2018-08-16T01:55:39.060Z] 01:55:39     INFO -         if (index >= 0 && index < aCount) {
[task 2018-08-16T01:55:39.061Z] 01:55:39     INFO -                           ~~~~~~^~~~~~~~
[task 2018-08-16T01:55:39.061Z] 01:55:39     INFO -  cc1plus: all warnings being treated as errors
[task 2018-08-16T01:55:39.062Z] 01:55:39     INFO -  /builds/worker/workspace/build/src/config/rules.mk:1088: recipe for target 'nsCSSAnonBoxes.i_o' failed
[task 2018-08-16T01:55:39.062Z] 01:55:39     INFO -  make[5]: *** [nsCSSAnonBoxes.i_o] Error 1
[task 2018-08-16T01:55:39.062Z] 01:55:39     INFO -  make[5]: Leaving directory '/builds/worker/workspace/build/src/obj-firefox/layout/style'
[task 2018-08-16T01:55:39.062Z] 01:55:39     INFO -  make[5]: *** Waiting for unfinished jobs....
[task 2018-08-16T01:55:39.063Z] 01:55:39     INFO -  make[5]: Entering directory '/builds/worker/workspace/build/src/obj-firefox/layout/base'
[task 2018-08-16T01:55:39.064Z] 01:55:39     INFO -  make[5]: Leaving directory '/builds/worker/workspace/build/src/obj-firefox/layout/base'
[task 2018-08-16T01:55:39.064Z] 01:55:39     INFO -  make[5]: Entering directory '/builds/worker/workspace/build/src/obj-firefox/layout/base'
[task 2018-08-16T01:55:39.065Z] 01:55:39     INFO -  make[5]: Leaving directory '/builds/worker/workspace/build/src/obj-firefox/layout/base'
[task 2018-08-16T01:55:39.241Z] 01:55:39     INFO -  make[5]: Entering directory '/builds/worker/workspace/build/src/obj-firefox/widget'
[task 2018-08-16T01:55:39.241Z] 01:55:39     INFO -  /builds/worker/workspace/build/src/sccache2/sccache /builds/worker/workspace/build/src/gcc/bin/g++ -m32 -o nsBaseDragService.i_o -c -I/builds/worker/workspace/build/src/obj-firefox/dist/stl_wrappers -I/builds/worker/workspace/build/src/obj-firefox/dist/system_wrappers -include /builds/worker/workspace/build/src/config/gcc_hidden.h -DNDEBUG=1 -DTRIMMED=1 -DMOZ_CROSS_PROCESS_IME -DOS_POSIX=1 -DOS_LINUX=1 -DSTATIC_EXPORTABLE_JS_API -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -I/builds/worker/workspace/build/src/widget -I/builds/worker/workspace/build/src/obj-firefox/widget -I/builds/worker/workspace/build/src/obj-firefox/ipc/ipdl/_ipdlheaders -I/builds/worker/workspace/build/src/ipc/chromium/src -I/builds/worker/workspace/build/src/ipc/glue -I/builds/worker/workspace/build/src/dom/base -I/builds/worker/workspace/build/src/dom/ipc -I/builds/worker/workspace/build/src/layout/base -I/builds/worker/workspace/build/src/layout/forms -I/builds/worker/workspace/build/src/layout/generic -I/builds/worker/workspace/build/src/layout/painting -I/builds/worker/workspace/build/src/layout/xul -I/builds/worker/workspace/build/src/layout/xul/tree -I/builds/worker/workspace/build/src/view -I/builds/worker/workspace/build/src/widget -I/builds/worker/workspace/build/src/widget/headless -I/builds/worker/workspace/build/src/widget/gtk -I/builds/worker/workspace/build/src/obj-firefox/dist/include -I/builds/worker/workspace/build/src/obj-firefox/dist/include/nspr -I/builds/worker/workspace/build/src/obj-firefox/dist/include/nss -fPIC -DMOZILLA_CLIENT -include /builds/worker/workspace/build/src/obj-firefox/mozilla-config.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wall -Wempty-body -Wignored-qualifiers -Woverloaded-virtual -Wpointer-arith -Wsign-compare -Wtype-limits -Wunreachable-code -Wwrite-strings -Wno-invalid-offsetof -Wduplicated-cond -Wno-error=maybe-uninitialized -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=coverage-mismatch -Wno-error=free-nonheap-object -Wformat -D_GLIBCXX_USE_CXX11_ABI=0 -fno-sized-deallocation -march=pentium-m -msse -msse2 -mfpmath=sse -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-exceptions -fno-strict-aliasing -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -g -O3 -fno-omit-frame-pointer -Werror -I/builds/worker/workspace/build/src/widget/gtk/compat-gtk3 -pthread -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gtk-3.0/unix-print -fprofile-generate  -MD -MP -MF .deps/nsBaseDragService.i_o.pp   /builds/worker/workspace/build/src/widget/nsBaseDragService.cpp
[task 2018-08-16T01:55:39.241Z] 01:55:39     INFO -  make[5]: Leaving directory '/builds/worker/workspace/build/src/obj-firefox/widget'
[task 2018-08-16T01:55:39.244Z] 01:55:39     INFO -  make[5]: Entering directory '/builds/worker/workspace/build/src/obj-firefox/layout/base/gtest'
[task 2018-08-16T01:55:39.244Z] 01:55:39     INFO -  mkdir -p '.deps/'
[task 2018-08-16T01:55:39.244Z] 01:55:39     INFO -  make[5]: Leaving directory '/builds/worker/workspace/build/src/obj-firefox/layout/base/gtest'
[task 2018-08-16T01:55:39.244Z] 01:55:39     INFO -  make[5]: Entering directory '/builds/worker/workspace/build/src/obj-firefox/layout/base/gtest'
[task 2018-08-16T01:55:39.244Z] 01:55:39     INFO -  layout/base/gtest
[task 2018-08-16T01:55:39.244Z] 01:55:39     INFO -  make[5]: Leaving directory '/builds/worker/workspace/build/src/obj-firefox/layout/base/gtest'
[task 2018-08-16T01:55:39.244Z] 01:55:39     INFO -  make[5]: Entering directory '/builds/worker/workspace/build/src/obj-firefox/layout/base/gtest'
[task 2018-08-16T01:55:39.244Z] 01:55:39     INFO -  make[5]: Leaving directory '/builds/worker/workspace/build/src/obj-firefox/layout/base/gtest'
[task 2018-08-16T01:55:39.433Z] 01:55:39     INFO -  make[5]: Entering directory '/builds/worker/workspace/build/src/obj-firefox/layout/style'
[task 2018-08-16T01:55:39.436Z] 01:55:39     INFO -  /builds/worker/workspace/build/src/sccache2/sccache /builds/worker/workspace/build/src/gcc/bin/g++ -m32 -o nsCSSPseudoElements.i_o -c -I/builds/worker/workspace/build/src/obj-firefox/dist/stl_wrappers -I/builds/worker/workspace/build/src/obj-firefox/dist/system_wrappers -include /builds/worker/workspace/build/src/config/gcc_hidden.h -DNDEBUG=1 -DTRIMMED=1 -DOS_POSIX=1 -DOS_LINUX=1 -DSTATIC_EXPORTABLE_JS_API -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -I/builds/worker/workspace/build/src/layout/style -I/builds/worker/workspace/build/src/obj-firefox/layout/style -I/builds/worker/workspace/build/src/obj-firefox/ipc/ipdl/_ipdlheaders -I/builds/worker/workspace/build/src/ipc/chromium/src -I/builds/worker/workspace/build/src/ipc/glue -I/builds/worker/workspace/build/src/layout/base -I/builds/worker/workspace/build/src/layout/generic -I/builds/worker/workspace/build/src/layout/svg -I/builds/worker/workspace/build/src/layout/xul -I/builds/worker/workspace/build/src/dom/base -I/builds/worker/workspace/build/src/dom/html -I/builds/worker/workspace/build/src/dom/xbl -I/builds/worker/workspace/build/src/dom/xul -I/builds/worker/workspace/build/src/image -I/builds/worker/workspace/build/src/obj-firefox/dist/include -I/builds/worker/workspace/build/src/obj-firefox/dist/include/nspr -I/builds/worker/workspace/build/src/obj-firefox/dist/include/nss -fPIC -DMOZILLA_CLIENT -include /builds/worker/workspace/build/src/obj-firefox/mozilla-config.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wall -Wempty-body -Wignored-qualifiers -Woverloaded-virtual -Wpointer-arith -Wsign-compare -Wtype-limits -Wunreachable-code -Wwrite-strings -Wno-invalid-offsetof -Wduplicated-cond -Wno-error=maybe-uninitialized -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=coverage-mismatch -Wno-error=free-nonheap-object -Wformat -D_GLIBCXX_USE_CXX11_ABI=0 -fno-sized-deallocation -march=pentium-m -msse -msse2 -mfpmath=sse -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-exceptions -fno-strict-aliasing -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -g -O3 -fno-omit-frame-pointer -Werror -fprofile-generate  -MD -MP -MF .deps/nsCSSPseudoElements.i_o.pp   /builds/worker/workspace/build/src/layout/style/nsCSSPseudoElements.cpp
[task 2018-08-16T01:55:39.436Z] 01:55:39     INFO -  In file included from /builds/worker/workspace/build/src/layout/style/nsCSSPseudoElements.cpp:16:0:
[task 2018-08-16T01:55:39.436Z] 01:55:39     INFO -  /builds/worker/workspace/build/src/obj-firefox/dist/include/nsStaticAtomUtils.h: In static member function 'static mozilla::Maybe<unsigned int> nsStaticAtomUtils::Lookup(nsAtom*, const nsStaticAtom*, uint32_t)':
[task 2018-08-16T01:55:39.436Z] 01:55:39     INFO -  /builds/worker/workspace/build/src/obj-firefox/dist/include/nsStaticAtomUtils.h:25:31: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
[task 2018-08-16T01:55:39.436Z] 01:55:39     INFO -         if (index >= 0 && index < aCount) {
[task 2018-08-16T01:55:39.436Z] 01:55:39     INFO -                           ~~~~~~^~~~~~~~
[task 2018-08-16T01:55:39.436Z] 01:55:39     INFO -  cc1plus: all warnings being treated as errors
[task 2018-08-16T01:55:39.436Z] 01:55:39     INFO -  /builds/worker/workspace/build/src/config/rules.mk:1088: recipe for target 'nsCSSPseudoElements.i_o' failed
[task 2018-08-16T01:55:39.436Z] 01:55:39     INFO -  make[5]: *** [nsCSSPseudoElements.i_o] Error 1
Flags: needinfo?(cam)
Pushed by cmccormack@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/5928090fcb23
Simplify nsStaticAtomUtils::Lookup. r=njn
https://hg.mozilla.org/mozilla-central/rev/5928090fcb23
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
Flags: needinfo?(cam)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: