Bug 1383155 - remove redundant casts of SN_TYPE; r?jimb draft
authorTom Tromey <tom@tromey.com>
Fri, 21 Jul 2017 08:13:19 -0600
changeset 613211 f1de1df4ac3d2ee6b0d59a523b1d90570de622f4
parent 611712 22e24b1ada9431c21c7f1f8a950d68ec94842c83
child 614517 a4a5d65f4e5d6f8a72cad91c6e5b61b0ef1d7962
push id69751
push userbmo:ttromey@mozilla.com
push dateFri, 21 Jul 2017 18:52:35 +0000
reviewersjimb
bugs1383155
milestone56.0a1
Bug 1383155 - remove redundant casts of SN_TYPE; r?jimb MozReview-Commit-ID: 8hwj36YwAxz
js/src/jsopcode.h
js/src/jsscript.cpp
js/src/shell/js.cpp
js/src/vm/CodeCoverage.cpp
js/src/vm/Debugger.cpp
--- a/js/src/jsopcode.h
+++ b/js/src/jsopcode.h
@@ -499,17 +499,17 @@ class SrcNoteLineScanner
         lineHeader = (offset == 0);
 
         if (SN_IS_TERMINATOR(sn))
             return;
 
         ptrdiff_t nextOffset;
         while ((nextOffset = offset + SN_DELTA(sn)) <= relpc && !SN_IS_TERMINATOR(sn)) {
             offset = nextOffset;
-            SrcNoteType type = (SrcNoteType) SN_TYPE(sn);
+            SrcNoteType type = SN_TYPE(sn);
             if (type == SRC_SETLINE || type == SRC_NEWLINE) {
                 if (type == SRC_SETLINE)
                     lineno = GetSrcNoteOffset(sn, 0);
                 else
                     lineno++;
 
                 if (offset == relpc)
                     lineHeader = true;
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -3281,17 +3281,17 @@ js::PCToLineNumber(unsigned startLine, j
      */
     ptrdiff_t offset = 0;
     ptrdiff_t target = pc - code;
     for (jssrcnote* sn = notes; !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn)) {
         offset += SN_DELTA(sn);
         if (offset > target)
             break;
 
-        SrcNoteType type = (SrcNoteType) SN_TYPE(sn);
+        SrcNoteType type = SN_TYPE(sn);
         if (type == SRC_SETLINE) {
             lineno = unsigned(GetSrcNoteOffset(sn, 0));
             column = 0;
         } else if (type == SRC_NEWLINE) {
             lineno++;
             column = 0;
         } else if (type == SRC_COLSPAN) {
             ptrdiff_t colspan = SN_OFFSET_TO_COLSPAN(GetSrcNoteOffset(sn, 0));
@@ -3333,17 +3333,17 @@ js::LineNumberToPC(JSScript* script, uns
         if (lineno >= target) {
             unsigned diff = lineno - target;
             if (diff < bestdiff) {
                 bestdiff = diff;
                 best = offset;
             }
         }
         offset += SN_DELTA(sn);
-        SrcNoteType type = (SrcNoteType) SN_TYPE(sn);
+        SrcNoteType type = SN_TYPE(sn);
         if (type == SRC_SETLINE) {
             lineno = unsigned(GetSrcNoteOffset(sn, 0));
         } else if (type == SRC_NEWLINE) {
             lineno++;
         }
     }
     if (best >= 0)
         offset = best;
@@ -3352,17 +3352,17 @@ out:
 }
 
 JS_FRIEND_API(unsigned)
 js::GetScriptLineExtent(JSScript* script)
 {
     unsigned lineno = script->lineno();
     unsigned maxLineNo = lineno;
     for (jssrcnote* sn = script->notes(); !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn)) {
-        SrcNoteType type = (SrcNoteType) SN_TYPE(sn);
+        SrcNoteType type = SN_TYPE(sn);
         if (type == SRC_SETLINE)
             lineno = unsigned(GetSrcNoteOffset(sn, 0));
         else if (type == SRC_NEWLINE)
             lineno++;
 
         if (maxLineNo < lineno)
             maxLineNo = lineno;
     }
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -2374,17 +2374,17 @@ SrcNotes(JSContext* cx, HandleScript scr
     unsigned offset = 0;
     unsigned colspan = 0;
     unsigned lineno = script->lineno();
     jssrcnote* notes = script->notes();
     unsigned switchTableEnd = 0, switchTableStart = 0;
     for (jssrcnote* sn = notes; !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn)) {
         unsigned delta = SN_DELTA(sn);
         offset += delta;
-        SrcNoteType type = (SrcNoteType) SN_TYPE(sn);
+        SrcNoteType type = SN_TYPE(sn);
         const char* name = js_SrcNoteSpec[type].name;
         if (!sp->jsprintf("%3u: %4u %5u [%4u] %-8s",
                           unsigned(sn - notes), lineno, offset, delta, name))
         {
             return false;
         }
 
         switch (type) {
--- a/js/src/vm/CodeCoverage.cpp
+++ b/js/src/vm/CodeCoverage.cpp
@@ -183,17 +183,17 @@ LCovSource::writeScript(JSScript* script
                 hits = counts->numExec();
         }
 
         // If we have additional source notes, walk all the source notes of the
         // current pc.
         if (snpc <= pc) {
             size_t oldLine = lineno;
             while (!SN_IS_TERMINATOR(sn) && snpc <= pc) {
-                SrcNoteType type = (SrcNoteType) SN_TYPE(sn);
+                SrcNoteType type = SN_TYPE(sn);
                 if (type == SRC_SETLINE)
                     lineno = size_t(GetSrcNoteOffset(sn, 0));
                 else if (type == SRC_NEWLINE)
                     lineno++;
                 else if (type == SRC_TABLESWITCH)
                     tableswitchExitOffset = GetSrcNoteOffset(sn, 0);
 
                 sn = SN_NEXT(sn);
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -5932,17 +5932,17 @@ class BytecodeRangeWithPosition : privat
   private:
     void updatePosition() {
         /*
          * Determine the current line number by reading all source notes up to
          * and including the current offset.
          */
         jsbytecode *lastLinePC = nullptr;
         while (!SN_IS_TERMINATOR(sn) && snpc <= frontPC()) {
-            SrcNoteType type = (SrcNoteType) SN_TYPE(sn);
+            SrcNoteType type = SN_TYPE(sn);
             if (type == SRC_COLSPAN) {
                 ptrdiff_t colspan = SN_OFFSET_TO_COLSPAN(GetSrcNoteOffset(sn, 0));
                 MOZ_ASSERT(ptrdiff_t(column) + colspan >= 0);
                 column += colspan;
                 lastLinePC = snpc;
             } else if (type == SRC_SETLINE) {
                 lineno = size_t(GetSrcNoteOffset(sn, 0));
                 column = 0;