mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-27 00:23:41 +09:00 
			
		
		
		
	Fix error log when loading issues caused by a xorm bug (#7271)
* fix error log when loading issues caused by a xorm bug * upgrade packages * fix fmt * fix Consistency * fix tests
This commit is contained in:
		
							
								
								
									
										49
									
								
								vendor/github.com/go-sql-driver/mysql/buffer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										49
									
								
								vendor/github.com/go-sql-driver/mysql/buffer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -22,17 +22,17 @@ const defaultBufSize = 4096 | ||||
| // The buffer is similar to bufio.Reader / Writer but zero-copy-ish | ||||
| // Also highly optimized for this particular use case. | ||||
| type buffer struct { | ||||
| 	buf     []byte // buf is a byte buffer who's length and capacity are equal. | ||||
| 	buf     []byte | ||||
| 	nc      net.Conn | ||||
| 	idx     int | ||||
| 	length  int | ||||
| 	timeout time.Duration | ||||
| } | ||||
|  | ||||
| // newBuffer allocates and returns a new buffer. | ||||
| func newBuffer(nc net.Conn) buffer { | ||||
| 	var b [defaultBufSize]byte | ||||
| 	return buffer{ | ||||
| 		buf: make([]byte, defaultBufSize), | ||||
| 		buf: b[:], | ||||
| 		nc:  nc, | ||||
| 	} | ||||
| } | ||||
| @@ -105,56 +105,43 @@ func (b *buffer) readNext(need int) ([]byte, error) { | ||||
| 	return b.buf[offset:b.idx], nil | ||||
| } | ||||
|  | ||||
| // takeBuffer returns a buffer with the requested size. | ||||
| // returns a buffer with the requested size. | ||||
| // If possible, a slice from the existing buffer is returned. | ||||
| // Otherwise a bigger buffer is made. | ||||
| // Only one buffer (total) can be used at a time. | ||||
| func (b *buffer) takeBuffer(length int) ([]byte, error) { | ||||
| func (b *buffer) takeBuffer(length int) []byte { | ||||
| 	if b.length > 0 { | ||||
| 		return nil, ErrBusyBuffer | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	// test (cheap) general case first | ||||
| 	if length <= cap(b.buf) { | ||||
| 		return b.buf[:length], nil | ||||
| 	if length <= defaultBufSize || length <= cap(b.buf) { | ||||
| 		return b.buf[:length] | ||||
| 	} | ||||
|  | ||||
| 	if length < maxPacketSize { | ||||
| 		b.buf = make([]byte, length) | ||||
| 		return b.buf, nil | ||||
| 		return b.buf | ||||
| 	} | ||||
|  | ||||
| 	// buffer is larger than we want to store. | ||||
| 	return make([]byte, length), nil | ||||
| 	return make([]byte, length) | ||||
| } | ||||
|  | ||||
| // takeSmallBuffer is shortcut which can be used if length is | ||||
| // known to be smaller than defaultBufSize. | ||||
| // shortcut which can be used if the requested buffer is guaranteed to be | ||||
| // smaller than defaultBufSize | ||||
| // Only one buffer (total) can be used at a time. | ||||
| func (b *buffer) takeSmallBuffer(length int) ([]byte, error) { | ||||
| func (b *buffer) takeSmallBuffer(length int) []byte { | ||||
| 	if b.length > 0 { | ||||
| 		return nil, ErrBusyBuffer | ||||
| 		return nil | ||||
| 	} | ||||
| 	return b.buf[:length], nil | ||||
| 	return b.buf[:length] | ||||
| } | ||||
|  | ||||
| // takeCompleteBuffer returns the complete existing buffer. | ||||
| // This can be used if the necessary buffer size is unknown. | ||||
| // cap and len of the returned buffer will be equal. | ||||
| // Only one buffer (total) can be used at a time. | ||||
| func (b *buffer) takeCompleteBuffer() ([]byte, error) { | ||||
| func (b *buffer) takeCompleteBuffer() []byte { | ||||
| 	if b.length > 0 { | ||||
| 		return nil, ErrBusyBuffer | ||||
| 		return nil | ||||
| 	} | ||||
| 	return b.buf, nil | ||||
| } | ||||
|  | ||||
| // store stores buf, an updated buffer, if its suitable to do so. | ||||
| func (b *buffer) store(buf []byte) error { | ||||
| 	if b.length > 0 { | ||||
| 		return ErrBusyBuffer | ||||
| 	} else if cap(buf) <= maxPacketSize && cap(buf) > cap(b.buf) { | ||||
| 		b.buf = buf[:cap(buf)] | ||||
| 	} | ||||
| 	return nil | ||||
| 	return b.buf | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user