Ver código fonte

Update protobuf.js

Lutz Roeder 5 anos atrás
pai
commit
a7fbf77acd
1 arquivos alterados com 26 adições e 22 exclusões
  1. 26 22
      source/protobuf.js

+ 26 - 22
source/protobuf.js

@@ -375,8 +375,7 @@ protobuf.TextReader = class {
     tag() {
         const name = this._token;
         this.next();
-        const separator = this._token;
-        if (separator !== '[' && separator !== '{') {
+        if (this._token !== '[' && this._token !== '{') {
             this.expect(':');
         }
         return name;
@@ -470,7 +469,7 @@ protobuf.TextReader = class {
             value = type[token];
         }
         else {
-            const value = Number.parseInt(token, 10);
+            value = Number.parseInt(token, 10);
             if (Number.isNaN(token - value)) {
                 throw new protobuf.Error("Couldn't parse enum '" + token + "'" + this.location());
             }
@@ -562,32 +561,37 @@ protobuf.TextReader = class {
     }
 
     skip() {
-        if (this._token === '{') {
-            const depth = this._depth;
-            this.start();
-            while (!this.end() || depth < this._depth) {
-                if (this._token === '{') {
-                    this.start();
+        switch (this._token) {
+            case '{': {
+                const depth = this._depth;
+                this.start();
+                while (!this.end() || depth < this._depth) {
+                    if (this._token === '{') {
+                        this.start();
+                    }
+                    else if (this._token !== '}') {
+                        this.next();
+                        this.match(';');
+                    }
                 }
-                else if (this._token !== '}') {
+                break;
+            }
+            case '[': {
+                this.next();
+                while (!this.last()) {
                     this.next();
-                    this.match(';');
+                    if (this._token === undefined) {
+                        this.handle(this._token);
+                    }
                 }
+                break;
             }
-        }
-        else if (this._token === '[') {
-            this.next();
-            while (!this.last()) {
+            default: {
                 this.next();
-                if (this._token === undefined) {
-                    this.handle(this._token);
-                }
+                this._semicolon();
+                break;
             }
         }
-        else {
-            this.next();
-            this._semicolon();
-        }
     }
 
     handle(token) {