From 164e50ac3f93bdd1291fb6fefefc7deca27ec846 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 23 Jun 2016 11:07:55 +0300 Subject: [PATCH] renaming: AcquireByteBuffer -> Acquire, ReleaseByteBuffer -> Release --- bytebuffer.go | 12 ++++++------ bytebuffer_example_test.go | 4 ++-- bytebuffer_test.go | 4 ++-- pool_test.go | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bytebuffer.go b/bytebuffer.go index 7790e43..9edf992 100644 --- a/bytebuffer.go +++ b/bytebuffer.go @@ -6,7 +6,7 @@ package bytebufferpool // ByteBuffer may be used with functions appending data to the given []byte // slice. See example code for details. // -// Use AcquireByteBuffer for obtaining an empty byte buffer. +// Use Acquire for obtaining an empty byte buffer. type ByteBuffer struct { // B is a byte buffer to use in append-like workloads. @@ -41,20 +41,20 @@ func (b *ByteBuffer) Reset() { b.B = b.B[:0] } -// AcquireByteBuffer returns an empty byte buffer from the pool. +// Acquire returns an empty byte buffer from the pool. // -// Acquired byte buffer may be returned to the pool via ReleaseByteBuffer call. +// Acquired byte buffer may be returned to the pool via Release call. // This reduces the number of memory allocations required for byte buffer // management. -func AcquireByteBuffer() *ByteBuffer { +func Acquire() *ByteBuffer { return defaultByteBufferPool.Acquire() } -// ReleaseByteBuffer returns byte buffer to the pool. +// Release returns byte buffer to the pool. // // ByteBuffer.B mustn't be touched after returning it to the pool. // Otherwise data races will occur. -func ReleaseByteBuffer(b *ByteBuffer) { +func Release(b *ByteBuffer) { defaultByteBufferPool.Release(b) } diff --git a/bytebuffer_example_test.go b/bytebuffer_example_test.go index 907fac2..1b7aa4a 100644 --- a/bytebuffer_example_test.go +++ b/bytebuffer_example_test.go @@ -7,7 +7,7 @@ import ( ) func ExampleByteBuffer() { - bb := bytebufferpool.AcquireByteBuffer() + bb := bytebufferpool.Acquire() bb.WriteString("first line\n") bb.Write([]byte("second line\n")) @@ -17,5 +17,5 @@ func ExampleByteBuffer() { // It is safe to release byte buffer now, since it is // no longer used. - bytebufferpool.ReleaseByteBuffer(bb) + bytebufferpool.Release(bb) } diff --git a/bytebuffer_test.go b/bytebuffer_test.go index c159c1b..d9ab904 100644 --- a/bytebuffer_test.go +++ b/bytebuffer_test.go @@ -32,12 +32,12 @@ func TestByteBufferAcquireReleaseConcurrent(t *testing.T) { func testByteBufferAcquireRelease(t *testing.T) { for i := 0; i < 10; i++ { expectedS := fmt.Sprintf("num %d", i) - b := AcquireByteBuffer() + b := Acquire() b.B = append(b.B, "num "...) b.B = append(b.B, fmt.Sprintf("%d", i)...) if string(b.B) != expectedS { t.Fatalf("unexpected result: %q. Expecting %q", b.B, expectedS) } - ReleaseByteBuffer(b) + Release(b) } } diff --git a/pool_test.go b/pool_test.go index dbb02e0..ca980d3 100644 --- a/pool_test.go +++ b/pool_test.go @@ -42,12 +42,12 @@ func testPoolVariousSizes(t *testing.T) { } func testAcquireRelease(t *testing.T, n int) { - bb := AcquireByteBuffer() + bb := Acquire() if len(bb.B) > 0 { t.Fatalf("non-empty byte buffer returned from acquire") } bb.B = allocNBytes(bb.B, n) - ReleaseByteBuffer(bb) + Release(bb) } func allocNBytes(dst []byte, n int) []byte {