Bug 1352082 - Avoid shifting a signed integer left in C++. r=wchen
MozReview-Commit-ID: 52YqyHAz2c3
This commit is contained in:
@@ -29,6 +29,7 @@ import nu.validator.htmlparser.annotation.NoLength;
|
||||
import nu.validator.htmlparser.annotation.NsUri;
|
||||
import nu.validator.htmlparser.annotation.Prefix;
|
||||
import nu.validator.htmlparser.annotation.QName;
|
||||
import nu.validator.htmlparser.annotation.Unsigned;
|
||||
import nu.validator.htmlparser.annotation.Virtual;
|
||||
import nu.validator.htmlparser.common.Interner;
|
||||
|
||||
@@ -276,7 +277,7 @@ public final class AttributeName
|
||||
// ]NOCPP]
|
||||
, Interner interner) {
|
||||
// XXX deal with offset
|
||||
int hash = AttributeName.bufToHash(buf, length);
|
||||
@Unsigned int hash = AttributeName.bufToHash(buf, length);
|
||||
int index = Arrays.binarySearch(AttributeName.ATTRIBUTE_HASHES, hash);
|
||||
if (index < 0) {
|
||||
return AttributeName.createAttributeName(
|
||||
@@ -310,9 +311,9 @@ public final class AttributeName
|
||||
* @param len
|
||||
* @return
|
||||
*/
|
||||
private static int bufToHash(@NoLength char[] buf, int len) {
|
||||
int hash2 = 0;
|
||||
int hash = len;
|
||||
private static @Unsigned int bufToHash(@NoLength char[] buf, int len) {
|
||||
@Unsigned int hash2 = 0;
|
||||
@Unsigned int hash = len;
|
||||
hash <<= 5;
|
||||
hash += buf[0] - 0x60;
|
||||
int j = len;
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.Arrays;
|
||||
import nu.validator.htmlparser.annotation.Inline;
|
||||
import nu.validator.htmlparser.annotation.Local;
|
||||
import nu.validator.htmlparser.annotation.NoLength;
|
||||
import nu.validator.htmlparser.annotation.Unsigned;
|
||||
import nu.validator.htmlparser.annotation.Virtual;
|
||||
import nu.validator.htmlparser.common.Interner;
|
||||
|
||||
@@ -108,7 +109,7 @@ public final class ElementName
|
||||
}
|
||||
|
||||
static ElementName elementNameByBuffer(@NoLength char[] buf, int offset, int length, Interner interner) {
|
||||
int hash = ElementName.bufToHash(buf, length);
|
||||
@Unsigned int hash = ElementName.bufToHash(buf, length);
|
||||
int index = Arrays.binarySearch(ElementName.ELEMENT_HASHES, hash);
|
||||
if (index < 0) {
|
||||
return new ElementName(Portability.newLocalNameFromBuffer(buf, offset, length, interner));
|
||||
@@ -131,8 +132,8 @@ public final class ElementName
|
||||
* @param len
|
||||
* @return
|
||||
*/
|
||||
private static int bufToHash(@NoLength char[] buf, int len) {
|
||||
int hash = len;
|
||||
private static @Unsigned int bufToHash(@NoLength char[] buf, int len) {
|
||||
@Unsigned int hash = len;
|
||||
hash <<= 5;
|
||||
hash += buf[0] - 0x60;
|
||||
int j = len;
|
||||
|
||||
@@ -106,7 +106,7 @@ nsHtml5AttributeName::SAME_LOCAL(nsIAtom* name)
|
||||
nsHtml5AttributeName*
|
||||
nsHtml5AttributeName::nameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
|
||||
{
|
||||
int32_t hash = nsHtml5AttributeName::bufToHash(buf, length);
|
||||
uint32_t hash = nsHtml5AttributeName::bufToHash(buf, length);
|
||||
int32_t index = nsHtml5AttributeName::ATTRIBUTE_HASHES.binarySearch(hash);
|
||||
if (index < 0) {
|
||||
return nsHtml5AttributeName::createAttributeName(nsHtml5Portability::newLocalNameFromBuffer(buf, offset, length, interner));
|
||||
@@ -120,11 +120,11 @@ nsHtml5AttributeName::nameByBuffer(char16_t* buf, int32_t offset, int32_t length
|
||||
}
|
||||
}
|
||||
|
||||
int32_t
|
||||
uint32_t
|
||||
nsHtml5AttributeName::bufToHash(char16_t* buf, int32_t len)
|
||||
{
|
||||
int32_t hash2 = 0;
|
||||
int32_t hash = len;
|
||||
uint32_t hash2 = 0;
|
||||
uint32_t hash = len;
|
||||
hash <<= 5;
|
||||
hash += buf[0] - 0x60;
|
||||
int32_t j = len;
|
||||
|
||||
@@ -76,7 +76,7 @@ class nsHtml5AttributeName
|
||||
static nsIAtom** SAME_LOCAL(nsIAtom* name);
|
||||
static nsHtml5AttributeName* nameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
|
||||
private:
|
||||
static int32_t bufToHash(char16_t* buf, int32_t len);
|
||||
static uint32_t bufToHash(char16_t* buf, int32_t len);
|
||||
int32_t* uri;
|
||||
nsIAtom** local;
|
||||
nsIAtom** prefix;
|
||||
|
||||
@@ -71,7 +71,7 @@ nsHtml5ElementName::isCustom()
|
||||
nsHtml5ElementName*
|
||||
nsHtml5ElementName::elementNameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
|
||||
{
|
||||
int32_t hash = nsHtml5ElementName::bufToHash(buf, length);
|
||||
uint32_t hash = nsHtml5ElementName::bufToHash(buf, length);
|
||||
int32_t index = nsHtml5ElementName::ELEMENT_HASHES.binarySearch(hash);
|
||||
if (index < 0) {
|
||||
return new nsHtml5ReleasableElementName(nsHtml5Portability::newLocalNameFromBuffer(buf, offset, length, interner));
|
||||
@@ -85,10 +85,10 @@ nsHtml5ElementName::elementNameByBuffer(char16_t* buf, int32_t offset, int32_t l
|
||||
}
|
||||
}
|
||||
|
||||
int32_t
|
||||
uint32_t
|
||||
nsHtml5ElementName::bufToHash(char16_t* buf, int32_t len)
|
||||
{
|
||||
int32_t hash = len;
|
||||
uint32_t hash = len;
|
||||
hash <<= 5;
|
||||
hash += buf[0] - 0x60;
|
||||
int32_t j = len;
|
||||
|
||||
@@ -71,7 +71,7 @@ class nsHtml5ElementName
|
||||
bool isCustom();
|
||||
static nsHtml5ElementName* elementNameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
|
||||
private:
|
||||
static int32_t bufToHash(char16_t* buf, int32_t len);
|
||||
static uint32_t bufToHash(char16_t* buf, int32_t len);
|
||||
nsHtml5ElementName(nsIAtom* name, nsIAtom* camelCaseName, int32_t flags);
|
||||
protected:
|
||||
explicit nsHtml5ElementName(nsIAtom* name);
|
||||
|
||||
Reference in New Issue
Block a user