Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use perfect hashing for namespace URIs.

  • Loading branch information...
commit 7e75d5d126966fdd34ece7c7044250bf3c35a072 1 parent 45d8c6f
@mbebenita authored
Showing with 10 additions and 15 deletions.
  1. +10 −15 src/avm2/parser.js
View
25 src/avm2/parser.js
@@ -327,7 +327,7 @@ var ShumwayNamespace = (function () {
}
} else if (this.isUnique()) {
// Make a psuedo unique id by concatenating current milliseconds to original uri
- this.uri = String(this.uri+Date.now());
+ this.uri = String(this.uri + Date.now());
}
this.uri = mangleNamespaceString(this.uri);
release || assert(kinds[this.kind]);
@@ -341,22 +341,17 @@ var ShumwayNamespace = (function () {
return str;
}
- function mangleNamespaceString(strIn) {
+ var perfectNamespaceHash = Object.create(null);
+ var perfectNamespaceHashCount = 0;
+
+ function mangleNamespaceString(str) {
if (!release) {
- return escapeString(strIn);
- }
- var buf = str2ab(strIn);
- var strOut = base64ArrayBuffer(buf).replace(/=/g, ""); // Erase padding
- return strOut;
-
- function str2ab(str) {
- var buf = new ArrayBuffer(str.length);
- var bufView = new Uint8Array(buf);
- for (var i=0, strLen=str.length; i<strLen; i++) {
- bufView[i] = str.charCodeAt(i);
- }
- return buf;
+ return escapeString(str);
+ }
+ if (str === "") {
+ return "";
}
+ return perfectNamespaceHash[str] || (perfectNamespaceHash[str] = "N" + perfectNamespaceHashCount++);
}
namespace.kindFromString = function kindFromString(str) {
Please sign in to comment.
Something went wrong with that request. Please try again.