summaryrefslogtreecommitdiff
path: root/src/pkg/fmt
AgeCommit message (Collapse)AuthorFilesLines
2010-02-28Count utf8 runes, not bytes when determining string width. NoteStephen Ma3-2/+6
that pad() still counts bytes, but it's currently only used for 1 byte runes. Fixes issue 612. R=r CC=golang-dev http://codereview.appspot.com/217064 Committer: Rob Pike <r@golang.org>
2010-02-25use []byte("abc") in place of []byte{'a', 'b', 'c'}Russ Cox1-9/+9
R=gri CC=golang-dev http://codereview.appspot.com/223059
2010-02-25strings: delete Runes, BytesRuss Cox1-6/+6
gofmt -w -r 'strings.Bytes(a) -> []byte(a)' src/cmd src/pkg test/bench gofmt -w -r 'strings.Runes(a) -> []int(a)' src/cmd src/pkg test/bench delete unused imports R=r CC=golang-dev http://codereview.appspot.com/224062
2010-02-25%q in fmt: if the object is a Stringer, use String() to get the value to quote.Rob Pike3-1/+11
R=rsc CC=golang-dev http://codereview.appspot.com/224051
2010-02-15Fix printing of named floating point types.Ian Lance Taylor2-4/+65
Try to avoid infinite recursion if String fails due to printing a bad type. Add test for String method with named basic types. R=r CC=golang-dev http://codereview.appspot.com/207102
2010-02-05handle nils safely in Printf.Rob Pike2-2/+12
add some tests for erroneous formats. R=rsc CC=golang-dev http://codereview.appspot.com/201058
2010-02-03finalizers; merge package malloc into package runtimeRuss Cox1-9/+9
R=r, cw CC=golang-dev http://codereview.appspot.com/198085
2010-02-02Change type of Printf's args to ... interface{}Rob Pike1-96/+205
R=rsc CC=golang-dev http://codereview.appspot.com/197043
2009-12-23fix up %pRob Pike1-4/+7
- use an interface {Get()} - implement Get for maps, slices - for slices, retrieves the address of the end of the array, which will give the same value for every slice of the same array. R=rsc CC=golang-dev http://codereview.appspot.com/179129
2009-12-22Allow %p on reference types, for debugging.Rob Pike2-18/+15
(Also fix case sensitivity in test for PTR inside fmt_test.go) Fixes issue 441. R=rsc, iant CC=golang-dev http://codereview.appspot.com/180112
2009-12-15 1) Change default gofmt default settings forRobert Griesemer3-409/+409
parsing and printing to new syntax. Use -oldparser to parse the old syntax, use -oldprinter to print the old syntax. 2) Change default gofmt formatting settings to use tabs for indentation only and to use spaces for alignment. This will make the code alignment insensitive to an editor's tabwidth. Use -spaces=false to use tabs for alignment. 3) Manually changed src/exp/parser/parser_test.go so that it doesn't try to parse the parser's source files using the old syntax (they have new syntax now). 4) gofmt -w src misc test/bench 2nd set of files. R=rsc CC=golang-dev http://codereview.appspot.com/179067
2009-12-06save a few ns by inlining (which mostly simplifies things anyway).Rob Pike2-114/+100
a couple of cleanups. don't keep big buffers in the free list. R=rsc CC=golang-dev http://codereview.appspot.com/166078
2009-12-06unexport Fmt. it's not needed outside this package any moreRob Pike2-205/+179
cleans up godoc's output for package fmt substantially. R=rsc CC=golang-dev http://codereview.appspot.com/165070
2009-12-06Make printing faster by avoiding mallocs and some other advances.Rob Pike3-378/+386
Roughly 33% faster for simple cases, probably more for complex ones. Before: mallocs per Sprintf(""): 4 mallocs per Sprintf("xxx"): 6 mallocs per Sprintf("%x"): 10 mallocs per Sprintf("%x %x"): 12 Now: mallocs per Sprintf(""): 2 mallocs per Sprintf("xxx"): 3 mallocs per Sprintf("%x"): 5 mallocs per Sprintf("%x %x"): 7 Speed improves because of avoiding mallocs and also by sharing a bytes.Buffer between print.go and format.go rather than copying the data back after each printed item. Before: fmt_test.BenchmarkSprintfEmpty 1000000 1346 ns/op fmt_test.BenchmarkSprintfString 500000 3461 ns/op fmt_test.BenchmarkSprintfInt 500000 3671 ns/op Now: fmt_test.BenchmarkSprintfEmpty 2000000 995 ns/op fmt_test.BenchmarkSprintfString 1000000 2745 ns/op fmt_test.BenchmarkSprintfInt 1000000 2391 ns/op fmt_test.BenchmarkSprintfIntInt 500000 3751 ns/op I believe there is more to get but this is a good milestone. R=rsc CC=golang-dev, hong http://codereview.appspot.com/166076
2009-12-03minor improvement to formatting: don't allocate padding strings every time.Rob Pike1-12/+19
R=rsc http://codereview.appspot.com/164090
2009-11-24Add benchmarks for commonly used routines.Trevor Strohman1-0/+18
R=rsc, r, r1 http://codereview.appspot.com/160046 Committer: Russ Cox <rsc@golang.org>
2009-11-23go: makes it build for the case $GOROOT has whitespacesSergio Luis O. B. Correia1-2/+2
the bash scripts and makefiles for building go didn't take into account the fact $GOROOT / $GOBIN could both be directories containing whitespaces, and was not possible to build it in such a situation. this commit adjusts the various makefiles/scripts to make it aware of that possibility, and now it builds successfully when using a path with whitespaces as well. Fixes issue 115. R=rsc, dsymonds1 http://codereview.appspot.com/157067 Committer: Russ Cox <rsc@golang.org>
2009-11-20gofmt -r 'α[β:len(α)] -> α[β:]' -w src/cmd src/pkgRuss Cox2-3/+3
R=r, gri CC=golang-dev http://codereview.appspot.com/156115
2009-11-20add unimplemented %+ and % (space) flags to floating-point print.Rob Pike2-11/+37
fix %E: was same as %e. add tests. Fixes issue 278. R=rsc CC=golang-dev http://codereview.appspot.com/157111
2009-11-17add a test for %+v in nested structures.Rob Pike1-0/+18
threw in an embedded one for good measure. R=rsc CC=golang-dev http://codereview.appspot.com/157058
2009-11-09 - replaced gofmt expression formatting algorithm withRobert Griesemer3-19/+19
rsc's algorithm - applied gofmt -w misc src - partial CL (remaining files in other CLs) R=rsc, r http://go/go-review/1026036
2009-11-09remove semis after statements in one-statement statement listsRobert Griesemer3-152/+152
R=rsc, r http://go/go-review/1025029
2009-11-06- fine-tuning of one-line func heuristic (nodes.go)Robert Griesemer2-69/+23
- enabled for function declarations (not just function literals) - applied gofmt -w $GOROOT/src (look for instance at src/pkg/debug/elf/elf.go) R=r, rsc CC=go-dev http://go/go-review/1026006
2009-11-05gofmt-ify template, time, unsafe, flag, fmtRobert Griesemer2-7/+7
(replacement for CLs 1017039, 1017041, 1017040, 1018054) R=r http://go/go-review/1018060
2009-10-08more lgtm files from gofmtRuss Cox1-1/+1
R=gri OCL=35485 CL=35488
2009-10-06apply gofmt to datafmt, ebnf, exec, expvar, flag, fmtRuss Cox3-270/+272
R=gri DELTA=456 (6 added, 3 deleted, 447 changed) OCL=35398 CL=35406
2009-09-17unused importsRuss Cox1-1/+0
R=r OCL=34731 CL=34731
2009-09-15more "declared and not used".Russ Cox2-6/+6
the last round omitted := range and only checked 1 out of N vars in a multi-var := R=r OCL=34624 CL=34638
2009-09-10fix indentationRuss Cox1-146/+146
R=r DELTA=166 (0 added, 0 deleted, 166 changed) OCL=34521 CL=34527
2009-08-31fmt: add verbs:Russ Cox3-65/+256
%E - upper case %e %G - upper case %g %#v - Go syntax R=r DELTA=332 (238 added, 47 deleted, 47 changed) OCL=34091 CL=34145
2009-08-28print the value using (in effect) %v when Printf is given mismatched args ↵Rob Pike2-2/+12
for its format Printf("%s", 2) gives %s(int=2) R=rsc DELTA=12 (10 added, 0 deleted, 2 changed) OCL=34042 CL=34044
2009-08-12convert low-level (used by testing) packages toRuss Cox3-67/+7
whole-package compilation. new Makefiles, tests now in separate package bytes flag fmt io math once os reflect strconv sync time utf8 delete import "xxx" in package xxx. inside package xxx, xxx is not declared anymore so s/xxx.//g delete file and package level forward declarations. note the new internal_test.go and sync and strconv to provide public access to internals during testing. the installed version of the package omits that file and thus does not open the internals to all clients. R=r OCL=33065 CL=33097
2009-08-10remove unnecessary pkg. referencesRuss Cox1-1/+1
R=r DELTA=95 (0 added, 0 deleted, 95 changed) OCL=33012 CL=33012
2009-08-03don't crash printing a nil mapRob Pike1-0/+14
R=rsc DELTA=19 (18 added, 0 deleted, 1 changed) OCL=32656 CL=32670
2009-07-31make %v and %p consistentRob Pike1-1/+1
R=rsc DELTA=1 (0 added, 0 deleted, 1 changed) OCL=32591 CL=32593
2009-07-30fix a long-standing typoRob Pike1-2/+2
R=rsc DELTA=2 (0 added, 0 deleted, 2 changed) OCL=32540 CL=32545
2009-07-10reflection for interface setRuss Cox1-1/+1
rename map access methods to Elem, SetElem. R=r DELTA=95 (66 added, 7 deleted, 22 changed) OCL=31456 CL=31469
2009-07-09printing mapsRob Pike2-18/+54
R=rsc DELTA=57 (39 added, 3 deleted, 15 changed) OCL=31424 CL=31430
2009-07-07fmt: use new reflect interface (CL 31107)Russ Cox1-158/+132
R=r DELTA=208 (37 added, 63 deleted, 108 changed) OCL=31111 CL=31281
2009-06-29io.StringBytes -> strings.BytesRuss Cox1-6/+7
io.ByteBuffer -> bytes.Buffer left io.ByteBuffer stub around for now, for protocol compiler. R=r OCL=30861 CL=30872
2009-06-23rename Formatter to State and Format to Formatter, for nomenclatural consistencyRob Pike2-6/+6
R=rsc DELTA=9 (0 added, 0 deleted, 9 changed) OCL=30658 CL=30658
2009-06-22document the verbs for PrintfRob Pike1-13/+61
R=rsc DELTA=61 (48 added, 0 deleted, 13 changed) OCL=30616 CL=30619
2009-06-22changes required if we disallow the implicit *Russ Cox1-12/+13
in cap, len, [], and range on maps, strings, and slices. R=r DELTA=57 (2 added, 12 deleted, 43 changed) OCL=30549 CL=30590
2009-06-09mv src/lib to src/pkgRob Pike4-0/+1553
tests: all.bash passes, gobuild still works, godoc still works. R=rsc OCL=30096 CL=30102