Performance improvements due to conditional parsing of IO data depending on selected fields.

On my machine, this gives a ~20% improvement in htop process time use with the default config.
This commit is contained in:
Hisham Muhammad
2013-05-24 22:46:01 +00:00
parent 5c2d84aba3
commit 6cfa9e0bf2
7 changed files with 61 additions and 6 deletions

View File

@ -122,11 +122,14 @@ void ColumnsPanel_update(Panel* super) {
// FIXME: this is crappily inefficient
free(this->settings->pl->fields);
this->settings->pl->fields = (ProcessField*) malloc(sizeof(ProcessField) * (size+1));
this->settings->pl->flags = 0;
for (int i = 0; i < size; i++) {
char* text = ((ListItem*) Panel_get(super, i))->value;
int j = ColumnsPanel_fieldNameToIndex(text);
if (j > 0)
if (j > 0) {
this->settings->pl->fields[i] = j;
this->settings->pl->flags |= Process_fieldFlags[j];
}
}
this->settings->pl->fields[size] = 0;
}