Bug 654399. Try to make sure we always hand out the same exact string buffer each time location.hash is gotten. r=roc

This commit is contained in:
Boris Zbarsky 2011-05-20 16:21:27 -04:00
parent 94c9744ce2
commit af0f5c831a
2 changed files with 10 additions and 0 deletions

View File

@ -1140,6 +1140,7 @@ protected:
nsresult CheckURL(nsIURI *url, nsIDocShellLoadInfo** aLoadInfo);
nsString mCachedHash;
nsWeakPtr mDocShell;
};

View File

@ -405,6 +405,15 @@ nsLocation::GetHash(nsAString& aHash)
aHash.Assign(PRUnichar('#'));
aHash.Append(unicodeRef);
}
if (aHash == mCachedHash) {
// Work around ShareThis stupidly polling location.hash every
// 5ms all the time by handing out the same exact string buffer
// we handed out last time.
aHash = mCachedHash;
} else {
mCachedHash = aHash;
}
}
return rv;