aboutsummaryrefslogtreecommitdiff
path: root/src/pkg
diff options
context:
space:
mode:
authorMarcel van Lohuizen <mpvl@golang.org>2012-05-30 17:47:56 +0200
committerMarcel van Lohuizen <mpvl@golang.org>2012-05-30 17:47:56 +0200
commitc633f85f65ece7bb063bd5dd7b06aff167ba5f59 (patch)
tree081ab4fc196fbcf6c3a2beb102205ce22bfcecea /src/pkg
parentcb9759d067289fef850251c9425b56446086e24c (diff)
downloadgo-c633f85f65ece7bb063bd5dd7b06aff167ba5f59.tar.xz
exp/locale/collate: avoid double building in maketables.go. Also added check.
R=r CC=golang-dev https://golang.org/cl/6202063
Diffstat (limited to 'src/pkg')
-rw-r--r--src/pkg/exp/locale/collate/build/builder.go21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/pkg/exp/locale/collate/build/builder.go b/src/pkg/exp/locale/collate/build/builder.go
index dfde8ac261..4451361e4d 100644
--- a/src/pkg/exp/locale/collate/build/builder.go
+++ b/src/pkg/exp/locale/collate/build/builder.go
@@ -22,6 +22,7 @@ import (
// - trie valueBlocks are currently 100K. There are a lot of sparse blocks
// and many consecutive values with the same stride. This can be further
// compacted.
+// - compress secondary weights into 8 bits.
// entry is used to keep track of a single entry in the collation element table
// during building. Examples of entries can be found in the Default Unicode
@@ -69,6 +70,7 @@ type Builder struct {
entry []*entry
t *table
err error
+ built bool
}
// NewBuilder returns a new Builder.
@@ -178,14 +180,16 @@ func (b *Builder) error(e error) {
}
func (b *Builder) build() (*table, error) {
- b.t = &table{}
-
- b.contractCJK()
- b.simplify() // requires contractCJK
- b.processExpansions() // requires simplify
- b.processContractions() // requires simplify
- b.buildTrie() // requires process*
+ if !b.built {
+ b.built = true
+ b.t = &table{}
+ b.contractCJK()
+ b.simplify() // requires contractCJK
+ b.processExpansions() // requires simplify
+ b.processContractions() // requires simplify
+ b.buildTrie() // requires process*
+ }
if b.err != nil {
return nil, b.err
}
@@ -334,6 +338,9 @@ func convertLargeWeights(elems [][]int) (res [][]int, err error) {
if p < firstLargePrimary {
continue
}
+ if p > 0xFFFF {
+ return elems, fmt.Errorf("found primary weight %X; should be <= 0xFFFF", p)
+ }
if p >= illegalPrimary {
ce[0] = illegalOffset + p - illegalPrimary
} else {