Skip to content

Commit e846b83

Browse files
authored
Apply fieldalignment fixes to optimize struct memory layout (#974)
1 parent 72fbe46 commit e846b83

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

middleware/throttle.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ type token struct{}
126126
type throttler struct {
127127
tokens chan token
128128
backlogTokens chan token
129+
retryAfterFn func(ctxDone bool) time.Duration
129130
backlogTimeout time.Duration
130131
statusCode int
131-
retryAfterFn func(ctxDone bool) time.Duration
132132
}
133133

134134
// setRetryAfterHeaderIfNeeded sets Retry-After HTTP header if corresponding retryAfterFn option of throttler is initialized.

middleware/wrap_writer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ type WrapResponseWriter interface {
7373
// http.ResponseWriter interface.
7474
type basicWriter struct {
7575
http.ResponseWriter
76-
wroteHeader bool
76+
tee io.Writer
7777
code int
7878
bytes int
79-
tee io.Writer
79+
wroteHeader bool
8080
discard bool
8181
}
8282

mux_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -644,11 +644,11 @@ func TestMuxHandlePatternValidation(t *testing.T) {
644644
testCases := []struct {
645645
name string
646646
pattern string
647+
method string
648+
path string
649+
expectedBody string
650+
expectedStatus int
647651
shouldPanic bool
648-
method string // Method to be used for the test request
649-
path string // Path to be used for the test request
650-
expectedBody string // Expected response body
651-
expectedStatus int // Expected HTTP status code
652652
}{
653653
// Valid patterns
654654
{

path_value_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ func TestPathValue(t *testing.T) {
1515
name string
1616
pattern string
1717
method string
18-
pathKeys []string
1918
requestPath string
2019
expectedBody string
20+
pathKeys []string
2121
}{
2222
{
2323
name: "Basic path value",

0 commit comments

Comments
 (0)