aboutsummaryrefslogtreecommitdiff
path: root/src/unicode
AgeCommit message (Collapse)Author
2021-02-24unicode: correctly handle negative runesDavid Benjamin
Is and isExcludingLatin did not handle negative runes when dispatching to is16. TestNegativeRune covers this along with the existing uint32 casts in IsGraphic, etc. (For tests, I picked the smallest non-Latin-1 code point in each range.) Updates #43254 Change-Id: I17261b91f0d2b5b5125d19219411b45c480df74f Reviewed-on: https://go-review.googlesource.com/c/go/+/280493 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2020-09-19unicode/utf8: document the handling of runes out of range in EncodeRuneAinar Garipov
Document the way EncodeRune currently handles runes which are out of range. Also add an example showing that behaviour. Change-Id: I0f8e7645ae053474ec319085a2bb6d7f73bc137c Reviewed-on: https://go-review.googlesource.com/c/go/+/255998 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Giovanni Bajo <rasky@develer.com> Trust: Giovanni Bajo <rasky@develer.com> Run-TryBot: Giovanni Bajo <rasky@develer.com> TryBot-Result: Go Bot <gobot@golang.org>
2020-09-10unicode/utf8: refactor benchmarks for FullRune functioneric fang
BenchmarkFullASCIIRune tests the performance of function utf8.FullRune, which will be inlined in BenchmarkFullASCIIRune. Since the return value of FullRune is not referenced, it will be removed as dead code. This CL makes the FullRune functions return value referenced by a global variable to avoid this point. In addition, this CL adds one more benchmark to cover more code paths, and puts them together as sub benchmarks of BenchmarkFullRune. Change-Id: I6e79f4c087adf70e351498a4b58d7482dcd1ec4a Reviewed-on: https://go-review.googlesource.com/c/go/+/233979 Run-TryBot: eric fang <eric.fang@arm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-08-20unicode: upgrade to Unicode 13.0.0Marcel van Lohuizen
Fixes #40755 Change-Id: I14b3977317994095db8ae1bd873c174641209356 Reviewed-on: https://go-review.googlesource.com/c/go/+/248765 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-22unicode/utf8: optimize Valid and ValidString for ASCII checksMartin Möhrmann
Add a fastpath that uses 32bit loads and compares to check 8 ASCII characters per loop iteration. This avoids the overhead of comparing and branching for every byte individually. Combining two 32bit loads into an uint32 allows the same code to be used for 32bit and 64bit platforms. amd64 (Intel i7-3520M): name old time/op new time/op delta ValidTenASCIIChars 15.6ns ± 4% 8.5ns ±14% -45.27% (p=0.000 n=10+10) ValidTenJapaneseChars 50.0ns ± 2% 52.7ns ±15% ~ (p=0.469 n=10+10) ValidStringTenASCIIChars 13.5ns ± 1% 7.9ns ± 5% -41.56% (p=0.000 n=10+10) ValidStringTenJapaneseChars 46.3ns ± 2% 45.8ns ± 2% ~ (p=0.085 n=10+10) arm (Raspberry Pi 3): name old time/op new time/op delta ValidTenASCIIChars 87.5ns ± 0% 58.5ns ± 0% -33.11% (p=0.000 n=9+10) ValidTenJapaneseChars 359ns ± 0% 384ns ± 0% +6.96% (p=0.000 n=10+9) ValidStringTenASCIIChars 87.5ns ± 0% 57.5ns ± 0% -34.31% (p=0.000 n=10+10) ValidStringTenJapaneseChars 356ns ± 0% 377ns ± 0% +5.90% (p=0.000 n=10+10) Change-Id: I9da942bddb250ee1f0ef7aabb4a8cb48edd9053e Reviewed-on: https://go-review.googlesource.com/c/go/+/228823 Run-TryBot: Martin Möhrmann <moehrmann@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-01-06all: fix typo in RuneSelf, runeSelf commentsTim Cooper
Fixes #36396 Change-Id: I52190f450fa9ac52fbf4ecdc814e954dc29029cd Reviewed-on: https://go-review.googlesource.com/c/go/+/213377 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-11-05unicode: upgrade to Unicode 12Marcel van Lohuizen
This does not include an upgrade of golang.org/x/net. This is optional and best done as a separate CL. Change-Id: Ifecc3fb6e3b7fe026b4ddefbe637186a3445b0bc Reviewed-on: https://go-review.googlesource.com/c/go/+/204658 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2019-10-06unicode/utf8: add link to formal UTF-8 description.Serhat Giydiren
Fixes #31590 Change-Id: I7fd6dcc5c34496776439ff0295f18b5fb5cb538a Reviewed-on: https://go-review.googlesource.com/c/go/+/199141 Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-04-25all: update to Unicode 11Marcel van Lohuizen
This does *not* update the vendored tables. A commit updating these tables should follow soon, Mostly generated running UNICODE_VERSION=11.0.0 in x/text. Manually updated next.txt file. Updates golang/go#27945. Change-Id: I939a01e235aeca898ee9afc99a531e7ad8444e12 Reviewed-on: https://go-review.googlesource.com/c/go/+/154420 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2019-04-25unicode/utf8: remove some bounds checks from DecodeRuneJosh Bleecher Snyder
The compiler couldn't quite see that reading p[2] and p[3] was safe. This change provides a few hints to help it. First, make sz an int throughout, rather than just when checking the input length. Second, use <= instead of == in later comparisons. name old time/op new time/op delta DecodeASCIIRune-8 2.62ns ± 3% 2.60ns ± 5% ~ (p=0.126 n=18+19) DecodeJapaneseRune-8 4.46ns ±10% 4.01ns ± 5% -10.00% (p=0.000 n=19+20) Change-Id: I2f78a17e38156fbf8b0f5dd6c07c20d6a47e9209 Reviewed-on: https://go-review.googlesource.com/c/go/+/173662 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-24unicode/utf8: use binary literalsJosh Bleecher Snyder
We were using hex literals and had the binary literal in a comment. When I was working with this code, I always referred to the comment. That's an indicator that we should just use the binary literal directly. Updates #19308 Change-Id: I2279cb8efb4ae5f2e1558c15979058ab09eb4f6f Reviewed-on: https://go-review.googlesource.com/c/go/+/173663 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-24unicode: update table using new generator in x/textMarcel van Lohuizen
The changes in Unicode 11 exposes a bug in maketables.go. We update the Unicode 10 tables using a new generator to minimize the changes upgrading to Unicode 11. This change switches over the generation from core to that in x/text. To properly update the tables one needs to run the generate in x/text anyway, so this makes that official. The RangeTable generator in x/text also generates slightly compacter tables. Updates golang/go#27945 See CL 154443 Change-Id: I6c59e082d5b8cd9e9332a32d8971061228581d66 Reviewed-on: https://go-review.googlesource.com/c/go/+/169617 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-24unicode: remove script testMarcel van Lohuizen
The script test requires a manual update on each new Unicode release, which interupts the automated flow. The test is removed in favor of one that fits within the automated scripts. See https://go-review.googlesource.com/c/text/+/169638. Updates golang/go#27945 Change-Id: I9c9f1e2a77f7baef17040ea09eec28d7cf55b5e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/169619 Reviewed-by: Russ Cox <rsc@golang.org>
2019-04-24unicode/utf8: make acceptRanges biggerJosh Bleecher Snyder
This avoids bounds checks in the calling code. The nominal increased size of the array in the binary is compensated for by the decreased size of the functions that call it. The benchmark changes are a bit scattered, but overall positive. name old time/op new time/op delta RuneCountTenASCIIChars-8 8.86ns ± 4% 7.93ns ± 5% -10.45% (p=0.000 n=45+49) RuneCountTenJapaneseChars-8 38.2ns ± 2% 37.2ns ± 1% -2.63% (p=0.000 n=44+41) RuneCountInStringTenASCIIChars-8 7.82ns ± 2% 8.70ns ± 2% +11.19% (p=0.000 n=43+43) RuneCountInStringTenJapaneseChars-8 39.3ns ± 9% 40.0ns ± 5% +1.59% (p=0.043 n=50+50) ValidTenASCIIChars-8 8.68ns ± 5% 8.74ns ± 5% ~ (p=0.070 n=50+48) ValidTenJapaneseChars-8 34.1ns ± 5% 36.8ns ± 4% +8.09% (p=0.000 n=45+50) ValidStringTenASCIIChars-8 9.76ns ± 7% 8.33ns ± 3% -14.59% (p=0.000 n=48+47) ValidStringTenJapaneseChars-8 37.7ns ± 8% 36.5ns ± 5% -3.12% (p=0.011 n=50+47) EncodeASCIIRune-8 2.60ns ± 1% 2.59ns ± 2% -0.24% (p=0.018 n=43+36) EncodeJapaneseRune-8 3.75ns ± 2% 4.56ns ± 6% +21.71% (p=0.000 n=41+50) DecodeASCIIRune-8 2.59ns ± 2% 2.59ns ± 2% ~ (p=0.350 n=44+41) DecodeJapaneseRune-8 4.29ns ± 2% 4.31ns ± 2% +0.61% (p=0.001 n=48+39) FullASCIIRune-8 0.87ns ± 6% 0.29ns ± 5% -67.31% (p=0.000 n=49+43) FullJapaneseRune-8 0.65ns ± 6% 0.65ns ± 4% ~ (p=0.375 n=50+49) [Geo mean] 7.02ns 6.51ns -7.19% Change-Id: I8d5d69c8d33ce2bff94785fba39a2203f9315cb0 Reviewed-on: https://go-review.googlesource.com/c/go/+/173537 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-28unicode: improve generated comments for categoriesWil Selwood
The comments on the category range tables in the unicode package are fairly redundent and require an external source to translate into human readable category names. This adds a look up table with the category descriptions and uses it if available when generating the comments for the range tables. Fixes #28954 Change-Id: I853e2d270def6492c2c1dd2ad0ec761a74c04e5d Reviewed-on: https://go-review.googlesource.com/c/151297 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-17unicode: fix SpecialCase to follow its docs & respect explict no-op mappingsBrad Fitzpatrick
If SpecialCase contains an explicit CaseRange with zero deltas, respect those and don't fall back to the default behavior. Fixes #25636 Change-Id: Ic554c6b3dd462b1b39c75194eec469b6ff4aa55b Reviewed-on: https://go-review.googlesource.com/117155 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
2018-06-01all: update comment URLs from HTTP to HTTPS, where possibleTim Cooper
Each URL was manually verified to ensure it did not serve up incorrect content. Change-Id: I4dc846227af95a73ee9a3074d0c379ff0fa955df Reviewed-on: https://go-review.googlesource.com/115798 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2018-05-06cmd/compile: optimize len([]rune(string))Martin Möhrmann
Adds a new runtime function to count runes in a string. Modifies the compiler to detect the pattern len([]rune(string)) and replaces it with the new rune counting runtime function. RuneCount/lenruneslice/ASCII 27.8ns ± 2% 14.5ns ± 3% -47.70% (p=0.000 n=10+10) RuneCount/lenruneslice/Japanese 126ns ± 2% 60ns ± 2% -52.03% (p=0.000 n=10+10) RuneCount/lenruneslice/MixedLength 104ns ± 2% 50ns ± 1% -51.71% (p=0.000 n=10+9) Fixes #24923 Change-Id: Ie9c7e7391a4e2cca675c5cdcc1e5ce7d523948b9 Reviewed-on: https://go-review.googlesource.com/108985 Run-TryBot: Martin Möhrmann <moehrmann@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-12-01Revert "go/printer: forbid empty line before first comment in block"Joe Tsai
This reverts commit 08f19bbde1b01227fdc2fa2d326e4029bb74dd96. Reason for revert: The changed transformation takes effect on a larger set of code snippets than expected. For example, this: func foo() { // Comment bar() } becomes: func foo() { // Comment bar() } This is an unintended consequence. Change-Id: Ifca88d6267dab8a8170791f7205124712bf8ace8 Reviewed-on: https://go-review.googlesource.com/81335 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Joe Tsai <joetsai@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-11-02go/printer: forbid empty line before first comment in blockJoe Tsai
To improve readability when exported fields are removed, forbid the printer from emitting an empty line before the first comment in a const, var, or type block. Also, when printing the "Has filtered or unexported fields." message, add an empty line before it to separate the message from the struct or interfact contents. Before the change: <<< type NamedArg struct { // Name is the name of the parameter placeholder. // // If empty, the ordinal position in the argument list will be // used. // // Name must omit any symbol prefix. Name string // Value is the value of the parameter. // It may be assigned the same value types as the query // arguments. Value interface{} // contains filtered or unexported fields } >>> After the change: <<< type NamedArg struct { // Name is the name of the parameter placeholder. // // If empty, the ordinal position in the argument list will be // used. // // Name must omit any symbol prefix. Name string // Value is the value of the parameter. // It may be assigned the same value types as the query // arguments. Value interface{} // contains filtered or unexported fields } >>> Fixes #18264 Change-Id: I9fe17ca39cf92fcdfea55064bd2eaa784ce48c88 Reviewed-on: https://go-review.googlesource.com/71990 Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2017-10-24unicode: update to Unicode 10.0.0Marcel van Lohuizen
Also includes all derived values as well as vendored packages. Generated by running UNICODE_VERSION=10.0.0 go generate in golang.org/x/text and modified by hand to add the tests and entries in next.txt for new script and properties. Closes Issue #21471 Change-Id: I1d10ee3887bd1fd3d5a756ee0d04bd6ec2814ba1 Reviewed-on: https://go-review.googlesource.com/63953 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Bonventre <andybons@golang.org>
2017-10-05all: revert "all: prefer strings.IndexByte over strings.Index"Marvin Stenger
This reverts https://golang.org/cl/65930. Fixes #22148 Change-Id: Ie0712621ed89c43bef94417fc32de9af77607760 Reviewed-on: https://go-review.googlesource.com/68430 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-25all: prefer strings.IndexByte over strings.IndexMarvin Stenger
strings.IndexByte was introduced in go1.2 and it can be used effectively wherever the second argument to strings.Index is exactly one byte long. This avoids generating unnecessary string symbols and saves a few calls to strings.Index. Change-Id: I1ab5edb7c4ee9058084cfa57cbcc267c2597e793 Reviewed-on: https://go-review.googlesource.com/65930 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-22all: use sort.Slice in a few more placesDaniel Martí
Do the low-hanging fruit - tiny Less functions that are used exactly once. This reduces the amount of code and puts the logic in a single place. Change-Id: I9d4544cd68de5a95e55019bdad1fca0a1dbfae9c Reviewed-on: https://go-review.googlesource.com/63171 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-19unicode: allow version to be passed by env varMarcel van Lohuizen
This, in turn, to make it work with x/text’s go generate. Also eliminates need to manually update version string in maketables.go. Change-Id: Id5a8b8e27bdce5b1b5920eb9223a2d27b889149a Reviewed-on: https://go-review.googlesource.com/63952 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Nigel Tao <nigeltao@golang.org>
2017-09-12unicode: speed-up is16/is32Ilya Tocar
Avoid division in common case. There are 5438 ranges in unicode/tables.go 4110 of them have stride 1. Stride 1 case got significantly faster. Other stride is a bit slower. Measured by import ( "testing" "unicode" ) func BenchmarkDiv1(b *testing.B) { rtb := &unicode.RangeTable{ R16: []unicode.Range16{ {0xa800, 0xdfff, 1}, // or 3 }, } for i := 0; i < b.N; i++ { unicode.Is(rtb, rune(0xc700)) } } Div1-6 15.6ns ± 1% 9.9ns ± 1% -36.54% (p=0.000 n=10+10) Div3-6 15.5ns ± 1% 16.1ns ± 1% +3.67% (p=0.000 n=10+10) Helps a bit with xml parsing from issue #21823 XMLsax-6 30.9s ± 0% 29.6s ± 0% -4.15% (p=0.000 n=10+9) Change-Id: Ibac1a91d7b9474d0c134b0add83e56caa62daa20 Reviewed-on: https://go-review.googlesource.com/63390 Run-TryBot: Ilya Tocar <ilya.tocar@intel.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-12unicode/utf8: make FullRune inlinableIlya Tocar
This has same readability and allows to inline FullRune for massive performance gain: FullASCIIRune-6 4.36ns ± 0% 1.25ns ± 0% -71.33% (p=0.000 n=8+10) FullJapaneseRune-6 4.70ns ± 0% 1.42ns ± 1% -69.68% (p=0.000 n=9+10) Change-Id: I95edd6292417a28aac244e40afb713596a087d93 Reviewed-on: https://go-review.googlesource.com/63332 Run-TryBot: Ilya Tocar <ilya.tocar@intel.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2017-06-15unicode: move scripts from FoldCategories to FoldScriptsRuss Cox
Copy-and-paste bug was putting scripts in the categories map. Fixes #18186. Change-Id: Ife9d9bdd346fe24e578dbb2a0aac7ef6e889ae68 Reviewed-on: https://go-review.googlesource.com/45830 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-13runtime, unicode: use consistent banner for generated codeBrad Fitzpatrick
Per golang.org/s/generatedcode Updates #nnn Change-Id: Ia7513ef6bd26c20b62b57b29f7770684a315d389 Reviewed-on: https://go-review.googlesource.com/45470 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Matt Layher <mdlayher@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-09all: single space after periodBrad Fitzpatrick
Done with grep & interactive search & replace, to double-check replacements. Not many remained after CL 20022. Fixes #18572 Change-Id: Idbe90ba3b584f9b9661d2bbd141607daaadfa41a Reviewed-on: https://go-review.googlesource.com/45270 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2016-10-26unicode/utf8: optimize ValidRuneJoe Tsai
Re-writing the switch statement as a single boolean expression reduces the number of branches that the compiler generates. It is also arguably easier to read as a pair of numeric ranges that valid runes can exist in. No test changes since the existing test does a good job of testing all of the boundaries. This change was to gain back some performance after a correctness fix done in http://golang.org/cl/32123. The correctness fix (CL/32123) slowed down the benchmarks slightly: benchmark old ns/op new ns/op delta BenchmarkIndexRune/10-4 19.3 21.6 +11.92% BenchmarkIndexRune/32-4 33.6 35.2 +4.76% Since the fix relies on utf8.ValidRune, this CL improves benchmarks: benchmark old ns/op new ns/op delta BenchmarkIndexRune/10-4 21.6 20.0 -7.41% BenchmarkIndexRune/32-4 35.2 33.5 -4.83% Change-Id: Ib1ca10a2e29c90e879a8ef9b7221c33e85d015d8 Reviewed-on: https://go-review.googlesource.com/32122 Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-17runtime: speed up non-ASCII rune decodingMartin Möhrmann
Copies utf8 constants and EncodeRune implementation from unicode/utf8. Adds a new decoderune implementation that is used by the compiler in code generated for ranging over strings. It does not handle ASCII runes since these are handled directly before calls to decoderune. The DecodeRuneInString implementation from unicode/utf8 is not used since it uses a lookup table that would increase the use of cpu caches. Adds more tests that check decoding of valid and invalid utf8 sequences. name old time/op new time/op delta RuneIterate/range2/ASCII-4 7.45ns ± 2% 7.45ns ± 1% ~ (p=0.634 n=16+16) RuneIterate/range2/Japanese-4 53.5ns ± 1% 49.2ns ± 2% -8.03% (p=0.000 n=20+20) RuneIterate/range2/MixedLength-4 46.3ns ± 1% 41.0ns ± 2% -11.57% (p=0.000 n=20+20) new: "".decoderune t=1 size=423 args=0x28 locals=0x0 old: "".charntorune t=1 size=666 args=0x28 locals=0x0 Change-Id: I1df1fdb385bb9ea5e5e71b8818ea2bf5ce62de52 Reviewed-on: https://go-review.googlesource.com/28490 Run-TryBot: Martin Möhrmann <martisch@uos.de> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-12unicode: change SimpleFold to handle invalid runesRuss Cox
Functions like ToLower and ToUpper return the invalid rune back, so we might as well do the same here. I changed my mind about panicking when I tried to document the behavior. Fixes #16690 (again). Change-Id: If1c68bfcd66daea160fd19948e7672b0e1add106 Reviewed-on: https://go-review.googlesource.com/30935 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2016-10-12unicode: panic if given rune is negative in SimpleFoldHiroshi Ioka
Fixes #16690 Change-Id: I6db588c4b0f23c5ec6bc9b85a488b60fab3f2f13 Reviewed-on: https://go-review.googlesource.com/30892 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-03unicode/utf8: reduce bounds checks in EncodeRuneMartin Möhrmann
Provide bounds elim hints in EncodeRune. name old time/op new time/op delta EncodeASCIIRune-4 2.69ns ± 2% 2.69ns ± 2% ~ (p=0.193 n=47+46) EncodeJapaneseRune-4 5.97ns ± 2% 5.38ns ± 2% -9.93% (p=0.000 n=49+50) Change-Id: I1a6dcffff3bdd64ab93c2130021e3b00981de4c8 Reviewed-on: https://go-review.googlesource.com/28492 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-06-28unicode: upgrade to version 9.0.0Marcel van Lohuizen
Changes beyond generated tables: - Now supports aliases to handle deprecated property classes. - Some Mongolian letters are now modifiers. Other changes: - strconv: newly generated table to be in sync - regexp/syntax: updated maxFold Fixes #16191 Change-Id: I56bdf21ee2f775f2a82d0465b3772faf5c24cb61 Reviewed-on: https://go-review.googlesource.com/24496 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-26unicode: improve SimpleFold performance for asciiEgon Elbre
This change significantly speeds up case-insensitive regexp matching. benchmark old ns/op new ns/op delta BenchmarkMatchEasy0i_32-8 2690 1473 -45.24% BenchmarkMatchEasy0i_1K-8 80404 42269 -47.43% BenchmarkMatchEasy0i_32K-8 3272187 2076118 -36.55% BenchmarkMatchEasy0i_1M-8 104805990 66503805 -36.55% BenchmarkMatchEasy0i_32M-8 3360192200 2126121600 -36.73% benchmark old MB/s new MB/s speedup BenchmarkMatchEasy0i_32-8 11.90 21.72 1.83x BenchmarkMatchEasy0i_1K-8 12.74 24.23 1.90x BenchmarkMatchEasy0i_32K-8 10.01 15.78 1.58x BenchmarkMatchEasy0i_1M-8 10.00 15.77 1.58x BenchmarkMatchEasy0i_32M-8 9.99 15.78 1.58x Issue #13288 Change-Id: I94af7bb29e75d60b4f6ee760124867ab271b9642 Reviewed-on: https://go-review.googlesource.com/16943 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-15all: remove unnecessary type conversionsMatthew Dempsky
cmd and runtime were handled separately, and I'm intentionally skipped syscall. This is the rest of the standard library. CL generated mechanically with github.com/mdempsky/unconvert. Change-Id: I9e0eff886974dedc37adb93f602064b83e469122 Reviewed-on: https://go-review.googlesource.com/22104 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02all: single space after period.Brad Fitzpatrick
The tree's pretty inconsistent about single space vs double space after a period in documentation. Make it consistently a single space, per earlier decisions. This means contributors won't be confused by misleading precedence. This CL doesn't use go/doc to parse. It only addresses // comments. It was generated with: $ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])') $ go test go/doc -update Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7 Reviewed-on: https://go-review.googlesource.com/20022 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dave Day <djd@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01all: make copyright headers consistent with one space after periodBrad Fitzpatrick
This is a subset of https://golang.org/cl/20022 with only the copyright header lines, so the next CL will be smaller and more reviewable. Go policy has been single space after periods in comments for some time. The copyright header template at: https://golang.org/doc/contribute.html#copyright also uses a single space. Make them all consistent. Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0 Reviewed-on: https://go-review.googlesource.com/20111 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24unicode/utf16: speed up and clean up Encode and EncodeRuneAlberto Donizetti
name old time/op new time/op delta EncodeValidASCII-4 74.1ns ± 1% 70.1ns ± 1% -5.46% (p=0.000 n=10+10) EncodeValidJapaneseChars-4 61.3ns ± 0% 58.9ns ± 0% -3.82% (p=0.000 n=10+10) EncodeRune-4 13.1ns ± 1% 9.8ns ± 0% -25.24% (p=0.000 n=10+9) Fixes #6957 Change-Id: I9dde6d77420c34c6e2ef3e6213bb6be9b58a3074 Reviewed-on: https://go-review.googlesource.com/19891 Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-23unicode/utf16: speed up and clean up DecodeAlberto Donizetti
name old time/op new time/op delta DecodeValidASCII-4 94.7ns ± 1% 87.4ns ± 1% -7.71% (p=0.000 n=10+9) DecodeValidJapaneseChars-4 91.0ns ± 2% 84.8ns ± 0% -6.77% (p=0.000 n=9+10) DecodeRune-4 16.5ns ± 0% 16.6ns ± 2% ~ (p=0.108 n=9+10) For #6957 Change-Id: I618c15c2a42ef7ec6a5cd163b7c3f1a65ca4ad01 Reviewed-on: https://go-review.googlesource.com/19826 Reviewed-by: Rob Pike <r@golang.org>
2016-02-23unicode/utf16: add benchmarksAlberto Donizetti
For #6957 Change-Id: Ic497c12f33efc933e9fe81f6cd1b2a0a01abbabf Reviewed-on: https://go-review.googlesource.com/19820 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-01unicode/utf8: add test for FullRuneMarcel van Lohuizen
Check that it now properly handles \xC0 and \xC1. Fixes #11733. Change-Id: I66cfe0d43f9d123d4c4509a3fa18b9b6380dfc39 Reviewed-on: https://go-review.googlesource.com/17225 Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-24unicode: add function level examplesCarlos Cirello
Change-Id: I9e968c03c6615a539b18701c84f830898242441d Reviewed-on: https://go-review.googlesource.com/13926 Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-24unicode/utf8: don't imply that the empty string is incorrect UTF-8Aaron Jacobs
Change-Id: Idd9523949ee4f2f304b12be39f8940ba34a420be Reviewed-on: https://go-review.googlesource.com/16361 Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-16unicode/utf8: table-based algorithm for decodingMarcel van Lohuizen
This simplifies covering all cases, reducing the number of branches and making unrolling for simpler functions manageable. This significantly improves performance of non-ASCII input. This change will also allow addressing Issue #11733 in an efficient manner. RuneCountTenASCIIChars-8 13.7ns ± 4% 13.5ns ± 2% ~ (p=0.116 n=7+8) RuneCountTenJapaneseChars-8 153ns ± 3% 74ns ± 2% -51.42% (p=0.000 n=8+8) RuneCountInStringTenASCIIChars-8 13.5ns ± 2% 12.5ns ± 3% -7.13% (p=0.000 n=8+7) RuneCountInStringTenJapaneseChars-8 145ns ± 2% 68ns ± 2% -53.21% (p=0.000 n=8+8) ValidTenASCIIChars-8 14.1ns ± 3% 12.5ns ± 5% -11.38% (p=0.000 n=8+8) ValidTenJapaneseChars-8 147ns ± 3% 71ns ± 4% -51.72% (p=0.000 n=8+8) ValidStringTenASCIIChars-8 12.5ns ± 3% 12.3ns ± 3% ~ (p=0.095 n=8+8) ValidStringTenJapaneseChars-8 146ns ± 4% 70ns ± 2% -51.62% (p=0.000 n=8+7) DecodeASCIIRune-8 5.91ns ± 2% 4.83ns ± 3% -18.28% (p=0.001 n=7+7) DecodeJapaneseRune-8 12.2ns ± 7% 8.5ns ± 3% -29.79% (p=0.000 n=8+7) FullASCIIRune-8 5.95ns ± 3% 4.27ns ± 1% -28.23% (p=0.000 n=8+7) FullJapaneseRune-8 12.0ns ± 6% 4.3ns ± 3% -64.39% (p=0.000 n=8+8) Change-Id: Iea1d6b0180cbbee1739659a0a38038126beecaca Reviewed-on: https://go-review.googlesource.com/16940 Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-16unicode/utf8: removed uses of ranging over stringMarcel van Lohuizen
Ranging over string is much slower than using DecodeRuneInString. See golang.org/issue/13162. Replacing ranging over a string with the implementation of the Bytes counterpart results in the following performance improvements: RuneCountInStringTenASCIIChars-8 43.0ns ± 1% 16.4ns ± 2% -61.80% (p=0.000 n=7+8) RuneCountInStringTenJapaneseChars-8 161ns ± 2% 154ns ± 2% -4.58% (p=0.000 n=8+8) ValidStringTenASCIIChars-8 52.2ns ± 1% 13.2ns ± 1% -74.62% (p=0.001 n=7+7) ValidStringTenJapaneseChars-8 173ns ± 2% 153ns ± 2% -11.78% (p=0.000 n=7+8) Update golang/go#13162 Change-Id: Ifc40a6a94bb3317f1f2d929d310bd2694645e9f6 Reviewed-on: https://go-review.googlesource.com/16695 Reviewed-by: Russ Cox <rsc@golang.org>
2015-10-26unicode/utf8: added benchmarksMarcel van Lohuizen
Cover some functions that weren't benched before and add InString variants if the underlying implementation is different. Note: compare (Valid|RuneCount)InString* to their (Valid|RuneCount)* counterparts. It shows, somewhat unexpectedly, that ranging over a string is *much* slower than using calls to DecodeRune. Results: In order to avoid a discrepancy in measuring the performance of core we could leave the names of the string-based measurements unchanged and suffix the added alternatives with Bytes. Compared to old: BenchmarkRuneCountTenASCIIChars-8 44.3 12.4 -72.01% BenchmarkRuneCountTenJapaneseChars-8 167 67.1 -59.82% BenchmarkEncodeASCIIRune-8 3.37 3.44 +2.08% BenchmarkEncodeJapaneseRune-8 7.19 7.24 +0.70% BenchmarkDecodeASCIIRune-8 5.41 5.53 +2.22% BenchmarkDecodeJapaneseRune-8 8.17 8.41 +2.94% All benchmarks: BenchmarkRuneCountTenASCIIChars-8 100000000 12.4 ns/op BenchmarkRuneCountTenJapaneseChars-8 20000000 67.1 ns/op BenchmarkRuneCountInStringTenASCIIChars-8 30000000 44.5 ns/op BenchmarkRuneCountInStringTenJapaneseChars-8 10000000 165 ns/op BenchmarkValidTenASCIIChars-8 100000000 12.5 ns/op BenchmarkValidTenJapaneseChars-8 20000000 71.1 ns/op BenchmarkValidStringTenASCIIChars-8 30000000 50.0 ns/op BenchmarkValidStringTenJapaneseChars-8 10000000 161 ns/op BenchmarkEncodeASCIIRune-8 500000000 3.44 ns/op BenchmarkEncodeJapaneseRune-8 200000000 7.24 ns/op BenchmarkDecodeASCIIRune-8 300000000 5.53 ns/op BenchmarkDecodeJapaneseRune-8 200000000 8.41 ns/op BenchmarkFullASCIIRune-8 500000000 3.91 ns/op BenchmarkFullJapaneseRune-8 300000000 4.22 ns/op Change-Id: I674d2ee4917b975a37717bbfa1082cc84dcd275e Reviewed-on: https://go-review.googlesource.com/14431 Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-24unicode: include rune 0 in RangeTables.Marcel van Lohuizen
All of Go passes. No changes for the text repo. Fixes #10153 Change-Id: I313369bf471c8974390a6d42075e5c54f6a81750 Reviewed-on: https://go-review.googlesource.com/13667 Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org>