Reduce use of malloc()
This commit is contained in:
+3
-3
@@ -128,9 +128,9 @@ void STMClient::output_new_frame( void )
|
|||||||
overlays.apply( new_state );
|
overlays.apply( new_state );
|
||||||
|
|
||||||
/* calculate minimal difference from where we are */
|
/* calculate minimal difference from where we are */
|
||||||
string diff = Terminal::Display::new_frame( !repaint_requested,
|
const string diff( Terminal::Display::new_frame( !repaint_requested,
|
||||||
*local_framebuffer,
|
*local_framebuffer,
|
||||||
new_state );
|
new_state ) );
|
||||||
swrite( STDOUT_FILENO, diff.data(), diff.size() );
|
swrite( STDOUT_FILENO, diff.data(), diff.size() );
|
||||||
*local_framebuffer = new_state;
|
*local_framebuffer = new_state;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -170,7 +170,7 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const
|
|||||||
/* have renditions changed? */
|
/* have renditions changed? */
|
||||||
if ( (!initialized)
|
if ( (!initialized)
|
||||||
|| (f.ds.get_renditions().sgr() != frame.current_rendition_string) ) {
|
|| (f.ds.get_renditions().sgr() != frame.current_rendition_string) ) {
|
||||||
frame.append( f.ds.get_renditions().sgr() );
|
frame.appendstring( f.ds.get_renditions().sgr() );
|
||||||
frame.current_rendition_string = f.ds.get_renditions().sgr();
|
frame.current_rendition_string = f.ds.get_renditions().sgr();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ void Display::put_cell( bool initialized, FrameState &frame, const Framebuffer &
|
|||||||
|
|
||||||
if ( frame.current_rendition_string != rendition_str ) {
|
if ( frame.current_rendition_string != rendition_str ) {
|
||||||
/* print renditions */
|
/* print renditions */
|
||||||
frame.append( rendition_str );
|
frame.appendstring( rendition_str );
|
||||||
frame.current_rendition_string = rendition_str;
|
frame.current_rendition_string = rendition_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -15,8 +15,16 @@ namespace Terminal {
|
|||||||
|
|
||||||
Framebuffer last_frame;
|
Framebuffer last_frame;
|
||||||
|
|
||||||
FrameState( const Framebuffer &s_last ) : x(0), y(0), str(), cursor_x(0), cursor_y(0), current_rendition_string(), last_frame( s_last ) {}
|
FrameState( const Framebuffer &s_last )
|
||||||
void append( std::string s ) { str.append( s ); }
|
: x(0), y(0),
|
||||||
|
str(), cursor_x(0), cursor_y(0), current_rendition_string(),
|
||||||
|
last_frame( s_last )
|
||||||
|
{
|
||||||
|
str.reserve( 1024 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void append( const char * s ) { str.append( s ); }
|
||||||
|
void appendstring( const std::string s ) { str.append( s ); }
|
||||||
|
|
||||||
void append_silent_move( int y, int x );
|
void append_silent_move( int y, int x );
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user