drop idna from names as we already are in the idn package and also avoid "else
if" when it's not necessary
This commit is contained in:
parent
0096e2aae0
commit
4071a397d6
4666
idn/idna_table.go
4666
idn/idna_table.go
File diff suppressed because it is too large
Load Diff
|
@ -274,30 +274,32 @@ func decode(b []byte) []byte {
|
|||
}
|
||||
|
||||
// isValidRune checks if the character is valid. We will look for the
|
||||
// character property in the IDNA table. For now we aren't checking special
|
||||
// character property in the code points list. For now we aren't checking special
|
||||
// rules in case of contextual property
|
||||
func isValidRune(r rune) bool {
|
||||
return findProperty(r) == idnaPropertyPVALID
|
||||
return findProperty(r) == propertyPVALID
|
||||
}
|
||||
|
||||
// findIDNProperty will try to check the code point property of the give
|
||||
// findProperty will try to check the code point property of the given
|
||||
// character. It will use a binary search algorithm as we have a slice of
|
||||
// ordered ranges (average case performance O(log n))
|
||||
func findProperty(r rune) idnaProperty {
|
||||
imin, imax := 0, len(idnaTable)
|
||||
func findProperty(r rune) property {
|
||||
imin, imax := 0, len(codePoints)
|
||||
|
||||
for imax >= imin {
|
||||
imid := (imin + imax) / 2
|
||||
|
||||
codePoint := idnaTable[imid]
|
||||
codePoint := codePoints[imid]
|
||||
if (codePoint.start == r && codePoint.end == 0) || (codePoint.start <= r && codePoint.end >= r) {
|
||||
return codePoint.state
|
||||
} else if (codePoint.end > 0 && codePoint.end < r) || (codePoint.end == 0 && codePoint.start < r) {
|
||||
}
|
||||
|
||||
if (codePoint.end > 0 && codePoint.end < r) || (codePoint.end == 0 && codePoint.start < r) {
|
||||
imin = imid + 1
|
||||
} else {
|
||||
imax = imid - 1
|
||||
}
|
||||
}
|
||||
|
||||
return idnaPropertyUnknown
|
||||
}
|
||||
return propertyUnknown
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue