Isolated algorithmic improvements.

* Fix inefficient STL use around Parser::UTF8Parser.
* Reduce typeid() usage, change some of it to a virtual method
* Do multiple-line scrolls as a single move
This commit is contained in:
John Hood
2014-05-10 15:25:40 -04:00
parent 3fa42cb8bb
commit 8fdcdc88cd
11 changed files with 89 additions and 63 deletions
+8 -8
View File
@@ -666,9 +666,10 @@ void PredictionEngine::new_user_byte( char the_byte, const Framebuffer &fb )
}
last_byte = the_byte;
list<Parser::Action *> actions( parser.input( the_byte ) );
Parser::Actions actions;
parser.input( the_byte, actions );
for ( list<Parser::Action *>::iterator it = actions.begin();
for ( Parser::Actions::iterator it = actions.begin();
it != actions.end();
it++ ) {
Parser::Action *act = *it;
@@ -678,7 +679,8 @@ void PredictionEngine::new_user_byte( char the_byte, const Framebuffer &fb )
act->name().c_str(), act->char_present ? act->ch : L'_' );
*/
if ( typeid( *act ) == typeid( Parser::Print ) ) {
const std::type_info& type_act = typeid( *act );
if ( type_act == typeid( Parser::Print ) ) {
/* make new prediction */
init_cursor( fb );
@@ -809,7 +811,7 @@ void PredictionEngine::new_user_byte( char the_byte, const Framebuffer &fb )
newline_carriage_return( fb );
}
}
} else if ( typeid( *act ) == typeid( Parser::Execute ) ) {
} else if ( type_act == typeid( Parser::Execute ) ) {
if ( act->char_present && (act->ch == 0x0d) /* CR */ ) {
become_tentative();
newline_carriage_return( fb );
@@ -817,10 +819,10 @@ void PredictionEngine::new_user_byte( char the_byte, const Framebuffer &fb )
// fprintf( stderr, "Execute 0x%x\n", act->ch );
become_tentative();
}
} else if ( typeid( *act ) == typeid( Parser::Esc_Dispatch ) ) {
} else if ( type_act == typeid( Parser::Esc_Dispatch ) ) {
// fprintf( stderr, "Escape sequence\n" );
become_tentative();
} else if ( typeid( *act ) == typeid( Parser::CSI_Dispatch ) ) {
} else if ( type_act == typeid( Parser::CSI_Dispatch ) ) {
if ( act->char_present && (act->ch == L'C') ) { /* right arrow */
init_cursor( fb );
if ( cursor().col < fb.ds.get_width() - 1 ) {
@@ -838,8 +840,6 @@ void PredictionEngine::new_user_byte( char the_byte, const Framebuffer &fb )
// fprintf( stderr, "CSI sequence %lc\n", act->ch );
become_tentative();
}
} else if ( typeid( *act ) == typeid( Parser::Clear ) ) {
}
delete act;