Thanks for the speedy response, Nigel.
Changes made with a question about the API inline.
On 2013/07/03 03:27:25, nigeltao wrote:
> Or just
> type point [numDimensions]uint32
> Also, int would seem easier to work with than uint32.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> return &block{
> minCorner: point{0x00, 0x00, 0x00},
> maxCorner: point{0xFF, 0xFF, 0xFF},
> points: p,
> }
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> Why is this type exported?
Apologies. Lost track of what should be exported to satisfy
heap.Interface within this code.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> Why is this method exported? We usually don't export methods unless we
have to,
> and we don't have to.
Brain fart syndrome?
On 2013/07/03 03:27:25, nigeltao wrote:
> You can inline this into the next line:
> sort.Sort(&pointSorter{
> points: points,
> by: by,
> })
> Or just inline the whole method in the one place it gets called below.
Then you
> wouldn't need to define a By type.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> I'd change ps to just s.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> Why is this type exported?
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> Drop the 0.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> This needs documentation comments.
> I'd also move it to writer.go, near where the Options type is defined.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> Was this the API that we agreed on??
Nope. I should have gotten clarification earlier on the thread. Sorry
about that.
Within the API we had discussed, you had suggested:
type Quantizer interface {
// Quantize sets dst.Palette as well as dst's pixels.
// TODO: would we ever want to pass a color.Palette in as a hint?
// Is it feasible to use dst.Palette's initial value as that?
// TODO: should dst be a draw.Image (with a fast path for
image.Paletted)?
// Would Quantize then have to return a color.Palette?
Quantize(dst image.Paletted, r image.Rectangle, src image.Image, sp
image.Point)
}
In the above API, what do r and sp specify exactly? Is r the bounds of
the src image that the palette should be quantized from? What is sp?
On 2013/07/03 03:27:25, nigeltao wrote:
> This needs documentation comments.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> Drop the 0.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> numDimensions is constant, use a (stack-allocated) array instead of a
slice.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> I wouldn't bother with an avgPoint variable, and just use
> sum[0] / len(block.points)
> directly here.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> The color.Color implementation could be a func, which is not a valid
map key
> type.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> m.Bounds() could be just bounds.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> Huh?
Since each pixel within a palette is represented by a single byte, and
Stride represents the distance between vertically adjacent bytes, the
width of the image rectangle is used.
Apologies if I’m missing something...?
On 2013/07/03 03:27:25, nigeltao wrote:
> Add a TODO to do this more efficiently.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> Do you call writer.WriteByte anywhere? You probably should, as it
should be more
> efficient that calling Write with 1-byte slices.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> Why is b.slice a field? Just use b.tmp[1:256] on the next line.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> Typo in "Extension".
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> Typo in "Application".
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> Making 1 write of 768 bytes will be more efficient than 256 writes of
3 bytes.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> You should probably return an error if any of these bounds overflow a
uint16.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> I'd just return an error if pm has an empty palette.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> If e.w was created above by bufio.NewWriter, then you may have
unflushed bytes
> here.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> Quantization is unnecessary work if m is already an *image.Paletted:
> pm, ok := m.(*image.Paletted)
> if !ok {
> // Quantize.
> }
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> All this below should just be a call to EncodeAll.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> readGif should be readGIF.
Done.
On 2013/07/03 03:27:25, nigeltao wrote:
> Why the ", 5"?
Oops. Removed.
On 2013/07/03 03:27:25, nigeltao wrote:
> I'd also like a benchmark for the quantization path. Your current
implementation
> seems very allocation-heavy.
Done.
https://codereview.appspot.com/10896043/