Skip to content

Commit f2bc671

Browse files
committed
use any and min builtins
1 parent 07c1c27 commit f2bc671

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

imageproxy.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func NewProxy(transport http.RoundTripper, cache Cache) *Proxy {
113113
Transport: &TransformingTransport{
114114
Transport: transport,
115115
CachingClient: client,
116-
log: func(format string, v ...interface{}) {
116+
log: func(format string, v ...any) {
117117
if proxy.Verbose {
118118
proxy.logf(format, v...)
119119
}
@@ -445,15 +445,15 @@ func should304(req *http.Request, resp *http.Response) bool {
445445
return false
446446
}
447447

448-
func (p *Proxy) log(v ...interface{}) {
448+
func (p *Proxy) log(v ...any) {
449449
if p.Logger != nil {
450450
p.Logger.Print(v...)
451451
} else {
452452
log.Print(v...)
453453
}
454454
}
455455

456-
func (p *Proxy) logf(format string, v ...interface{}) {
456+
func (p *Proxy) logf(format string, v ...any) {
457457
if p.Logger != nil {
458458
p.Logger.Printf(format, v...)
459459
} else {
@@ -474,7 +474,7 @@ type TransformingTransport struct {
474474
// responses are properly cached.
475475
CachingClient *http.Client
476476

477-
log func(format string, v ...interface{})
477+
log func(format string, v ...any)
478478
}
479479

480480
// RoundTrip implements the http.RoundTripper interface.

transform.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,8 @@ func cropParams(m image.Image, opt Options) image.Rectangle {
212212
}
213213

214214
// bottom right coordinate of crop
215-
x1 := x0 + w
216-
if x1 > imgW {
217-
x1 = imgW
218-
}
219-
y1 := y0 + h
220-
if y1 > imgH {
221-
y1 = imgH
222-
}
215+
x1 := min(x0+w, imgW)
216+
y1 := min(y0+h, imgH)
223217

224218
return image.Rect(x0, y0, x1, y1)
225219
}

0 commit comments

Comments
 (0)