catbuf

Up / catbuf-0.1.0.tar.gz

catbuf is Ruby's string buffer just for fast appending operation.

Requirements

How fast is it?

Ruby 1.6.x users may get better performance and less memory usage than using String#<<. (In Ruby 1.7.x or later, appending to String is fast enough.) See following benchmark result:

Examples

See benchmark/benchmark.rb.

Usage

Require "catbuf", and CatBuffer class is provided.

CatBuffer.new(capacity = nil)

Creates new string buffer with capacity capacity. (default: 16)

CatBuffer#<<(string)
CatBuffer#append(string)

Appends string to buffer.

CatBuffer#string

Obtain stored string as String object.

CatBuffer#size
CatBuffer#length

Obtain length of stored string.

CatBuffer#ensure_capacity(capacity)

Ensures the buffer capacity length to be more than capacity.

CatBuffer#capacity

Obtain current buffer capacity length.

Copyright and License Notice

This program is free software distributed under BSD-style license term described in file COPYING.

Copyright 2003-, Shirai,Kaoru <shirai@korinkan.co.jp>