Skip to content

Commit

Permalink
Optimize allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
gen2brain committed Apr 18, 2024
1 parent 948a017 commit a3de2f2
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,15 @@ func decode(r io.Reader, configOnly bool) (image.Image, image.Config, error) {
return nil, cfg, ErrMemWrite
}

res, err = _alloc.Call(ctx, 4)
res, err = _alloc.Call(ctx, 4*3)
if err != nil {
return nil, cfg, fmt.Errorf("alloc: %w", err)
}
widthPtr := res[0]
defer _free.Call(ctx, widthPtr)

res, err = _alloc.Call(ctx, 4)
if err != nil {
return nil, cfg, fmt.Errorf("alloc: %w", err)
}
heightPtr := res[0]
defer _free.Call(ctx, heightPtr)
defer _free.Call(ctx, res[0])

res, err = _alloc.Call(ctx, 4)
if err != nil {
return nil, cfg, fmt.Errorf("alloc: %w", err)
}
stridePtr := res[0]
defer _free.Call(ctx, stridePtr)
widthPtr := res[0]
heightPtr := res[0] + 4
stridePtr := res[0] + 8

res, err = _decode.Call(ctx, inPtr, uint64(inSize), 1, widthPtr, heightPtr, stridePtr, 0)
if err != nil {
Expand Down

0 comments on commit a3de2f2

Please sign in to comment.