mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-14 08:21:27 -04:00
vt: split up action_param() to three separate functions
We’re already switching on the next VT input byte in the state machine; no need to if...else if in action_param() too. That is, split up action_param() into three: * action_param_new() * action_param_new_subparam() * action_param() This makes the code cleaner, and hopefully slightly faster. Next, to improve performance further, only check for (sub)parameter overflow in action_param_new() and action_param_subparam(). Add pointers to the VT struct that points to the currently active parameter and sub-parameter. When the number of parameters (or sub-parameters) overflow, warn, and then point the parameter pointer to a "dummy" value in the VT struct. This way, we don’t have to check anything in action_param().
This commit is contained in:
parent
690d78edfa
commit
d88bea5e22
2 changed files with 75 additions and 68 deletions
|
|
@ -180,8 +180,10 @@ struct grid {
|
|||
};
|
||||
|
||||
struct vt_subparams {
|
||||
unsigned value[16];
|
||||
uint8_t idx;
|
||||
unsigned *cur;
|
||||
unsigned value[16];
|
||||
unsigned dummy;
|
||||
};
|
||||
|
||||
struct vt_param {
|
||||
|
|
@ -197,8 +199,10 @@ struct vt {
|
|||
#endif
|
||||
char32_t utf8;
|
||||
struct {
|
||||
struct vt_param v[16];
|
||||
uint8_t idx;
|
||||
struct vt_param *cur;
|
||||
struct vt_param v[16];
|
||||
struct vt_param dummy;
|
||||
} params;
|
||||
|
||||
uint32_t private; /* LSB=priv0, MSB=priv3 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue