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:
@@ -46,16 +46,17 @@ string Complete::act( const string &str )
|
||||
{
|
||||
for ( unsigned int i = 0; i < str.size(); i++ ) {
|
||||
/* parse octet into up to three actions */
|
||||
list<Action *> actions( parser.input( str[ i ] ) );
|
||||
parser.input( str[ i ], actions );
|
||||
|
||||
/* apply actions to terminal and delete them */
|
||||
for ( list<Action *>::iterator it = actions.begin();
|
||||
for ( Actions::iterator it = actions.begin();
|
||||
it != actions.end();
|
||||
it++ ) {
|
||||
Action *act = *it;
|
||||
act->act_on_terminal( &terminal );
|
||||
delete act;
|
||||
}
|
||||
actions.clear();
|
||||
}
|
||||
|
||||
return terminal.read_octets_to_host();
|
||||
|
||||
@@ -48,6 +48,11 @@ namespace Terminal {
|
||||
Terminal::Emulator terminal;
|
||||
Terminal::Display display;
|
||||
|
||||
// Only used locally by act(), but kept here as a performance optimization,
|
||||
// to avoid construction/destruction. It must always be empty
|
||||
// outside calls to act() to keep horrible things from happening.
|
||||
Parser::Actions actions;
|
||||
|
||||
typedef std::list< std::pair<uint64_t, uint64_t> > input_history_type;
|
||||
input_history_type input_history;
|
||||
uint64_t echo_ack;
|
||||
@@ -56,7 +61,7 @@ namespace Terminal {
|
||||
|
||||
public:
|
||||
Complete( size_t width, size_t height ) : parser(), terminal( width, height ), display( false ),
|
||||
input_history(), echo_ack( 0 ) {}
|
||||
actions(), input_history(), echo_ack( 0 ) {}
|
||||
|
||||
std::string act( const std::string &str );
|
||||
std::string act( const Parser::Action *act );
|
||||
|
||||
Reference in New Issue
Block a user