go-tinyqr

An experimental minimal QR Code generator  http://go-qrcode.appspot.com
git clone https://git.ce9e.org/go-tinyqr.git

NameSize
.gitignore14B
LICENSE1055B
README.md1916B
bitset.go490B
ecc.go3000B
gf.go3102B
go.mod40B
qrcode.go2852B
qrcode/main.go194B
render.go3311B
version.go4565B

go-tinyqr

This is an experimental QR code generator that aims to be as small as possible. It is based on go-qrcode by Tom Harwood.

In order to reduce the size, I mostly removed options:

Fixing all of these options leads to slightly worse results, but massivly simplifies the code. For example, it allows to hardcode the complete format info.

Still, generating QR codes stays complex. I had hoped that I can reduce this down to a small library that can just be copied to a new project. But it is still ~1000 loc.

I did not remove support for different versions (sizes). Concentrating on a single version would have similar benefits to the other optimizations in terms of size, but I feel that the loss of flexibility would be much more relevant in this case.

Reduction in code size

| file | old | new | diff | | ---------- | ---: | --: | ---: | | gf.go | 92 | 83 | -10% | | ecc.go | 177 | 102 | -42% | | bitset.go | 174 | 22 | -87% | | version.go | 2927 | 416 | -86% | | render.go | 439 | 147 | -67% | | qrcode.go | 649 | 119 | -82% | | total | 4528 | 902 | -80% |

This table compares b6ab6a4 (old) and f88a46e (new). The numbers were measured using sloc. In cases where I combined files I added up the line counts of the old files.

The biggest single change is that I was able to remove ~2000 lines of version information for error correction levels that I didn't use.

Links