Skip to content

Commit

Permalink
Moved empty noCopy struct to the top of container structs. See @stemar94
Browse files Browse the repository at this point in the history
 's comment at golang/go#12884 for details
  • Loading branch information
valyala committed Mar 5, 2016
1 parent 9f43aa1 commit 8280b7a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions args.go
Expand Up @@ -36,11 +36,11 @@ var argsPool = &sync.Pool{
//
// Args instance MUST NOT be used from concurrently running goroutines.
type Args struct {
noCopy noCopy

args []argsKV
bufKV argsKV
buf []byte

noCopy noCopy
}

type argsKV struct {
Expand Down
8 changes: 4 additions & 4 deletions client.go
Expand Up @@ -122,6 +122,8 @@ var defaultClient Client
//
// It is safe calling Client methods from concurrently running goroutines.
type Client struct {
noCopy noCopy

// Client name. Used in User-Agent request header.
//
// Default client name is used if not set.
Expand Down Expand Up @@ -201,8 +203,6 @@ type Client struct {
mLock sync.Mutex
m map[string]*HostClient
ms map[string]*HostClient

noCopy noCopy
}

// Get appends url contents to dst and returns it as body.
Expand Down Expand Up @@ -407,6 +407,8 @@ type DialFunc func(addr string) (net.Conn, error)
//
// It is safe calling HostClient methods from concurrently running goroutines.
type HostClient struct {
noCopy noCopy

// Comma-separated list of upstream HTTP server host addresses,
// which are passed to Dial in round-robin manner.
//
Expand Down Expand Up @@ -513,8 +515,6 @@ type HostClient struct {

readerPool sync.Pool
writerPool sync.Pool

noCopy noCopy
}

type clientConn struct {
Expand Down
4 changes: 2 additions & 2 deletions cookie.go
Expand Up @@ -47,6 +47,8 @@ var cookiePool = &sync.Pool{
//
// Cookie instance MUST NOT be used from concurrently running goroutines.
type Cookie struct {
noCopy noCopy

key []byte
value []byte
expire time.Time
Expand All @@ -55,8 +57,6 @@ type Cookie struct {

bufKV argsKV
buf []byte

noCopy noCopy
}

// CopyTo copies src cookie to c.
Expand Down
8 changes: 4 additions & 4 deletions header.go
Expand Up @@ -18,6 +18,8 @@ import (
// ResponseHeader instance MUST NOT be used from concurrently running
// goroutines.
type ResponseHeader struct {
noCopy noCopy

disableNormalizing bool
noHTTP11 bool
connectionClose bool
Expand All @@ -33,8 +35,6 @@ type ResponseHeader struct {
bufKV argsKV

cookies []argsKV

noCopy noCopy
}

// RequestHeader represents HTTP request header.
Expand All @@ -45,6 +45,8 @@ type ResponseHeader struct {
// RequestHeader instance MUST NOT be used from concurrently running
// goroutines.
type RequestHeader struct {
noCopy noCopy

disableNormalizing bool
noHTTP11 bool
connectionClose bool
Expand All @@ -70,8 +72,6 @@ type RequestHeader struct {
cookies []argsKV

rawHeaders []byte

noCopy noCopy
}

// SetContentRange sets 'Content-Range: bytes startPos-endPos/contentLength'
Expand Down
8 changes: 4 additions & 4 deletions http.go
Expand Up @@ -18,6 +18,8 @@ import (
//
// Request instance MUST NOT be used from concurrently running goroutines.
type Request struct {
noCopy noCopy

// Request header
//
// Copying Header by value is forbidden. Use pointer to Header instead.
Expand All @@ -37,8 +39,6 @@ type Request struct {
// Group bool members in order to reduce Request object size.
parsedURI bool
parsedPostArgs bool

noCopy noCopy
}

// Response represents HTTP response.
Expand All @@ -48,6 +48,8 @@ type Request struct {
//
// Response instance MUST NOT be used from concurrently running goroutines.
type Response struct {
noCopy noCopy

// Response header
//
// Copying Header by value is forbidden. Use pointer to Header instead.
Expand All @@ -64,8 +66,6 @@ type Response struct {
// Response.Write() skips writing body if set to true.
// Use it for writing HEAD responses.
SkipBody bool

noCopy noCopy
}

// SetRequestURI sets RequestURI.
Expand Down
8 changes: 4 additions & 4 deletions server.go
Expand Up @@ -137,6 +137,8 @@ type RequestHandler func(ctx *RequestCtx)
//
// It is safe to call Server methods from concurrently running goroutines.
type Server struct {
noCopy noCopy

// Handler for processing incoming requests.
Handler RequestHandler

Expand Down Expand Up @@ -270,8 +272,6 @@ type Server struct {
writerPool sync.Pool
hijackConnPool sync.Pool
bytePool sync.Pool

noCopy noCopy
}

// TimeoutHandler creates RequestHandler, which returns StatusRequestTimeout
Expand Down Expand Up @@ -345,6 +345,8 @@ func CompressHandlerLevel(h RequestHandler, level int) RequestHandler {
// running goroutines. The only exception is TimeoutError*, which may be called
// while other goroutines accessing RequestCtx.
type RequestCtx struct {
noCopy noCopy

// Incoming request.
//
// Copying Request by value is forbidden. Use pointer to Request instead.
Expand Down Expand Up @@ -376,8 +378,6 @@ type RequestCtx struct {
timeoutTimer *time.Timer

hijackHandler HijackHandler

noCopy noCopy
}

// HijackHandler must process the hijacked connection c.
Expand Down
4 changes: 2 additions & 2 deletions uri.go
Expand Up @@ -36,6 +36,8 @@ var uriPool = &sync.Pool{
//
// URI instance MUST NOT be used from concurrently running goroutines.
type URI struct {
noCopy noCopy

pathOriginal []byte
scheme []byte
path []byte
Expand All @@ -50,8 +52,6 @@ type URI struct {
requestURI []byte

h *RequestHeader

noCopy noCopy
}

// CopyTo copies uri contents to dst.
Expand Down

0 comments on commit 8280b7a

Please sign in to comment.