Граф коммитов

8 Коммитов

Автор SHA1 Сообщение Дата
Dmitri Shuralyov 0608babe04 pic: don't make a string copy when writing image
Previously, the entire image was encoded into a buffer,
then encoded to a base64 string, which was concatenated
with another string, and written to stdout in one swoop.

We can do this more efficiently by writing the PNG image
to a base64 encoder directly, and using buffered I/O to
batch writes to stdout into moderately-sized chunks.

As an added bonus, though really the main motivation for
doing this optimization now, this helps avoid triggering
the golang/go#38751 issue on the Go Playground.

Switch to the best compression level instead of the default,
reducing encoded image size at the cost of extra computation.
Playground snippets need to be transferred over the network
and kept in storage, so it should be a favorable trade-off.

This CL was based on CL 232177.

For golang/go#38751.

Change-Id: I565fe538aa15910caaff98be156ac64b0d35fff4
Co-authored-by: Alexander Rakoczy <alex@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/tour/+/232867
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
2020-05-08 15:55:40 +00:00
Dmitri Shuralyov 6a4383abac pic: add a test
It's hard to write a normal test because ShowImage writes
to os.Stdout unconditionally. Add an example test instead.

Change-Id: I52e02908e94aa212a05c058edb4f504851b5bb8d
Reviewed-on: https://go-review.googlesource.com/c/tour/+/232866
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
2020-05-08 15:55:20 +00:00
Dmitri Shuralyov 8ec2108c3a pic: document package
Effective Go¹ says every package should have a package comment,
and every exported name in a package should have a doc comment.

This package is mentioned in the Go tour. Let's set a good example.

¹ https://golang.org/doc/effective_go.html#commentary

Change-Id: Iac561c7530fc49d5ff17c51d925151ec8319ef24
Reviewed-on: https://go-review.googlesource.com/c/tour/+/232865
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
2020-05-08 15:55:07 +00:00
Andrew Gerrand 27c8720404 all: add import comments
Change-Id: I30a2b0dec44e3a41e06e418c3d7162da36b60510
Reviewed-on: https://go-review.googlesource.com/5710
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-03-09 02:04:06 +00:00
Andrew Gerrand 1aa93960d4 go-tour: panic on failed png encode in tour/pic.ShowImage
Fixes #59.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/10862043
2013-07-03 08:30:20 +10:00
Rob Pike 8922303df6 gotour: update to go 1
R=adg, adg
CC=golang-dev
https://golang.org/cl/5495071
2011-12-16 18:00:43 -08:00
Andrew Gerrand fe07700382 update for r60 2011-09-12 17:38:04 +10:00
Andrew Gerrand ab572597e3 initial commit 2011-07-14 16:39:17 +10:00