Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(255)

Delta Between Two Patch Sets: src/pkg/unicode/maketables.go

Issue 78870047: code review 78870047: unicode: rearrange static data to decrease binary size (Closed)
Left Patch Set: diff -r e8ca57933a8f https://code.google.com/p/go Created 10 years ago
Right Patch Set: diff -r e8ca57933a8f https://code.google.com/p/go Created 10 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/unicode/tables.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build ignore 5 // +build ignore
6 6
7 // Unicode table generator. 7 // Unicode table generator.
8 // Data read from the web. 8 // Data read from the web.
9 9
10 package main 10 package main
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 // next range: start looking where this range ends 548 // next range: start looking where this range ends
549 next = hi + 1 549 next = hi + 1
550 } 550 }
551 fmt.Print(header) 551 fmt.Print(header)
552 fmt.Print(rt.String()) 552 fmt.Print(rt.String())
553 fmt.Print("}\n") 553 fmt.Print("}\n")
554 } 554 }
555 555
556 // As of Go 1.3, the gc toolchain gives every static array 556 // As of Go 1.3, the gc toolchain gives every static array
557 // its own symbol in the binary, with concomitant symbol 557 // its own symbol in the binary, with concomitant symbol
558 // overhead and padding. Rather than generate static RangeTables 558 // overhead and padding. When there are many small static
559 // which have their own Range16 and Range32 slices, each of 559 // slices, this adds noticeably to the binary size; each
560 // which will have their own static backing array, create 560 // static slice is given its own static backing array.
561 // shared backing arrays that all RangeTables can slice into. 561 // To save space, we create shared backing arrays that
562 // Since there are so many RangeTables, using shared arrays 562 // all RangeTables can slice into for their Range16 and
563 // reduces the binary size noticeably. See also issue 7599. 563 // Range32 slices. See also issue 7599.
564 //
565 // The allRange tables accumulate all ranges that will be used.
566 var ( 564 var (
567 allRange16 []unicode.Range16 565 allRange16 []unicode.Range16
568 allRange32 []unicode.Range32 566 allRange32 []unicode.Range32
569 ) 567 )
570 568
571 // rangeTable is a single code-gen *RangeTable. 569 // rangeTable is a single code-gen *RangeTable.
572 // Additions to a rangeTable modify the allRange tables. 570 // Additions to a rangeTable modify the allRange tables.
573 // As a result, new rangeTables must not be created or 571 // As a result, new rangeTables must not be created or
574 // used until previous rangeTables are complete. 572 // used until previous rangeTables are complete.
575 type rangeTable struct { 573 type rangeTable struct {
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 range16Count := len(allRange16) 1350 range16Count := len(allRange16)
1353 range32Count := len(allRange32) 1351 range32Count := len(allRange32)
1354 fmt.Println() 1352 fmt.Println()
1355 fmt.Printf("// Range entries: %d 16-bit, %d 32-bit, %d total.\n", range1 6Count, range32Count, range16Count+range32Count) 1353 fmt.Printf("// Range entries: %d 16-bit, %d 32-bit, %d total.\n", range1 6Count, range32Count, range16Count+range32Count)
1356 range16Bytes := range16Count * 3 * 2 1354 range16Bytes := range16Count * 3 * 2
1357 range32Bytes := range32Count * 3 * 4 1355 range32Bytes := range32Count * 3 * 4
1358 fmt.Printf("// Range bytes: %d 16-bit, %d 32-bit, %d total.\n", range16B ytes, range32Bytes, range16Bytes+range32Bytes) 1356 fmt.Printf("// Range bytes: %d 16-bit, %d 32-bit, %d total.\n", range16B ytes, range32Bytes, range16Bytes+range32Bytes)
1359 fmt.Println() 1357 fmt.Println()
1360 fmt.Printf("// Fold orbit bytes: %d pairs, %d bytes\n", foldPairCount, f oldPairCount*2*2) 1358 fmt.Printf("// Fold orbit bytes: %d pairs, %d bytes\n", foldPairCount, f oldPairCount*2*2)
1361 } 1359 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b