Created
May 14, 2015 02:59
-
-
Save lf94/47c72ed22de2f57085a8 to your computer and use it in GitHub Desktop.
GNU Moe's buffer data management
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Basic_buffer::add_line( const char * const buf, const int len ) | |
{ | |
data.back().append( buf, len ); | |
if( data.back().size() && data.back()[data.back().size()-1] == '\n' ) | |
{ | |
if( data.size() >= data.capacity() && data.size() >= 10000 ) | |
data.reserve( data.size() + ( data.size() / 10 ) ); | |
data.push_back( std::string() ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment