Source File
trie.go
Belonging Package
golang.org/x/net/idna
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package idna
// appendMapping appends the mapping for the respective rune. isMapped must be
// true. A mapping is a categorization of a rune as defined in UTS #46.
func ( info) ( []byte, string) []byte {
:= int( >> indexShift)
if &xorBit == 0 {
:= mappings[:]
return append(, [1:[0]+1]...)
}
= append(, ...)
if &inlineXOR == inlineXOR {
// TODO: support and handle two-byte inline masks
[len()-1] ^= byte()
} else {
for := len() - int(xorData[]); < len(); ++ {
++
[] ^= xorData[]
}
}
return
}
// Sparse block handling code.
type valueRange struct {
value uint16 // header: value:stride
lo, hi byte // header: lo:n
}
type sparseBlocks struct {
values []valueRange
offset []uint16
}
var idnaSparse = sparseBlocks{
values: idnaSparseValues[:],
offset: idnaSparseOffset[:],
}
// Don't use newIdnaTrie to avoid unconditional linking in of the table.
var trie = &idnaTrie{}
// lookup determines the type of block n and looks up the value for b.
// For n < t.cutoff, the block is a simple lookup table. Otherwise, the block
// is a list of ranges with an accompanying value. Given a matching range r,
// the value for b is by r.value + (b - r.lo) * stride.
func ( *sparseBlocks) ( uint32, byte) uint16 {
:= .offset[]
:= .values[]
:= + 1
:= + uint16(.lo)
for < {
:= + (-)/2
:= .values[]
if .lo <= && <= .hi {
return .value + uint16(-.lo)*.value
}
if < .lo {
=
} else {
= + 1
}
}
return 0
}
The pages are generated with Golds v0.4.9. (GOOS=linux GOARCH=amd64)