Commit d247eb6b authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf ui: Shorten ui_browser member names



LKML-Reference: <new-submission>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ef8f34aa
Loading
Loading
Loading
Loading
+18 −18
Original line number Original line Diff line number Diff line
@@ -450,8 +450,8 @@ static int map_browser__search(struct map_browser *self)
	if (sym != NULL) {
	if (sym != NULL) {
		u32 *idx = symbol__browser_index(sym);
		u32 *idx = symbol__browser_index(sym);
			
			
		self->b.first_visible_entry = &sym->rb_node;
		self->b.top = &sym->rb_node;
		self->b.index = self->b.first_visible_entry_idx = *idx;
		self->b.index = self->b.top_idx = *idx;
	} else
	} else
		ui_helpline__fpush("%s not found!", target);
		ui_helpline__fpush("%s not found!", target);


@@ -967,7 +967,7 @@ static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self,
			}
			}


			SLsmg_set_color(color);
			SLsmg_set_color(color);
			SLsmg_gotorc(self->b.top + row, self->b.left);
			SLsmg_gotorc(self->b.y + row, self->b.x);
			slsmg_write_nstring(" ", offset + extra_offset);
			slsmg_write_nstring(" ", offset + extra_offset);
			slsmg_printf("%c ", folded_sign);
			slsmg_printf("%c ", folded_sign);
			slsmg_write_nstring(str, width);
			slsmg_write_nstring(str, width);
@@ -1030,7 +1030,7 @@ static int hist_browser__show_callchain_node(struct hist_browser *self,
		}
		}


		s = callchain_list__sym_name(chain, ipstr, sizeof(ipstr));
		s = callchain_list__sym_name(chain, ipstr, sizeof(ipstr));
		SLsmg_gotorc(self->b.top + row, self->b.left);
		SLsmg_gotorc(self->b.y + row, self->b.x);
		SLsmg_set_color(color);
		SLsmg_set_color(color);
		slsmg_write_nstring(" ", offset);
		slsmg_write_nstring(" ", offset);
		slsmg_printf("%c ", folded_sign);
		slsmg_printf("%c ", folded_sign);
@@ -1110,7 +1110,7 @@ static int hist_browser__show_entry(struct hist_browser *self,
		}
		}


		SLsmg_set_color(color);
		SLsmg_set_color(color);
		SLsmg_gotorc(self->b.top + row, self->b.left);
		SLsmg_gotorc(self->b.y + row, self->b.x);
		if (symbol_conf.use_callchain) {
		if (symbol_conf.use_callchain) {
			slsmg_printf("%c ", folded_sign);
			slsmg_printf("%c ", folded_sign);
			width -= 2;
			width -= 2;
@@ -1138,10 +1138,10 @@ static unsigned int hist_browser__refresh(struct ui_browser *self)
	struct rb_node *nd;
	struct rb_node *nd;
	struct hist_browser *hb = container_of(self, struct hist_browser, b);
	struct hist_browser *hb = container_of(self, struct hist_browser, b);


	if (self->first_visible_entry == NULL)
	if (self->top == NULL)
		self->first_visible_entry = rb_first(&hb->hists->entries);
		self->top = rb_first(&hb->hists->entries);


	for (nd = self->first_visible_entry; nd; nd = rb_next(nd)) {
	for (nd = self->top; nd; nd = rb_next(nd)) {
		struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
		struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);


		if (h->filtered)
		if (h->filtered)
@@ -1244,7 +1244,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
		nd = hists__filter_entries(rb_first(self->entries));
		nd = hists__filter_entries(rb_first(self->entries));
		break;
		break;
	case SEEK_CUR:
	case SEEK_CUR:
		nd = self->first_visible_entry;
		nd = self->top;
		goto do_offset;
		goto do_offset;
	case SEEK_END:
	case SEEK_END:
		nd = hists__filter_prev_entries(rb_last(self->entries));
		nd = hists__filter_prev_entries(rb_last(self->entries));
@@ -1258,7 +1258,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
	 * Moves not relative to the first visible entry invalidates its
	 * Moves not relative to the first visible entry invalidates its
	 * row_offset:
	 * row_offset:
	 */
	 */
	h = rb_entry(self->first_visible_entry, struct hist_entry, rb_node);
	h = rb_entry(self->top, struct hist_entry, rb_node);
	h->row_offset = 0;
	h->row_offset = 0;


	/*
	/*
@@ -1286,7 +1286,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
				} else {
				} else {
					h->row_offset += offset;
					h->row_offset += offset;
					offset = 0;
					offset = 0;
					self->first_visible_entry = nd;
					self->top = nd;
					break;
					break;
				}
				}
			}
			}
@@ -1294,7 +1294,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
			if (nd == NULL)
			if (nd == NULL)
				break;
				break;
			--offset;
			--offset;
			self->first_visible_entry = nd;
			self->top = nd;
		} while (offset != 0);
		} while (offset != 0);
	} else if (offset < 0) {
	} else if (offset < 0) {
		while (1) {
		while (1) {
@@ -1307,7 +1307,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
					} else {
					} else {
						h->row_offset += offset;
						h->row_offset += offset;
						offset = 0;
						offset = 0;
						self->first_visible_entry = nd;
						self->top = nd;
						break;
						break;
					}
					}
				} else {
				} else {
@@ -1317,7 +1317,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
					} else {
					} else {
						h->row_offset = h->nr_rows + offset;
						h->row_offset = h->nr_rows + offset;
						offset = 0;
						offset = 0;
						self->first_visible_entry = nd;
						self->top = nd;
						break;
						break;
					}
					}
				}
				}
@@ -1327,7 +1327,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
			if (nd == NULL)
			if (nd == NULL)
				break;
				break;
			++offset;
			++offset;
			self->first_visible_entry = nd;
			self->top = nd;
			if (offset == 0) {
			if (offset == 0) {
				/*
				/*
				 * Last unfiltered hist_entry, check if it is
				 * Last unfiltered hist_entry, check if it is
@@ -1342,7 +1342,7 @@ static void ui_browser__hists_seek(struct ui_browser *self,
			first = false;
			first = false;
		}
		}
	} else {
	} else {
		self->first_visible_entry = nd;
		self->top = nd;
		h = rb_entry(nd, struct hist_entry, rb_node);
		h = rb_entry(nd, struct hist_entry, rb_node);
		h->row_offset = 0;
		h->row_offset = 0;
	}
	}
@@ -1463,7 +1463,7 @@ static int hist_browser__run(struct hist_browser *self, const char *title,
		switch (es->u.key) {
		switch (es->u.key) {
		case 'd': { /* Debug */
		case 'd': { /* Debug */
			static int seq;
			static int seq;
			struct hist_entry *h = rb_entry(self->b.first_visible_entry,
			struct hist_entry *h = rb_entry(self->b.top,
							struct hist_entry, rb_node);
							struct hist_entry, rb_node);
			ui_helpline__pop();
			ui_helpline__pop();
			ui_helpline__fpush("%d: nr_ent=(%d,%d), height=%d, idx=%d, fve: idx=%d, row_off=%d, nrows=%d",
			ui_helpline__fpush("%d: nr_ent=(%d,%d), height=%d, idx=%d, fve: idx=%d, row_off=%d, nrows=%d",
@@ -1471,7 +1471,7 @@ static int hist_browser__run(struct hist_browser *self, const char *title,
					   self->hists->nr_entries,
					   self->hists->nr_entries,
					   self->b.height,
					   self->b.height,
					   self->b.index,
					   self->b.index,
					   self->b.first_visible_entry_idx,
					   self->b.top_idx,
					   h->row_offset, h->nr_rows);
					   h->row_offset, h->nr_rows);
		}
		}
			continue;
			continue;
+28 −29
Original line number Original line Diff line number Diff line
@@ -49,7 +49,7 @@ void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whenc
		pos = head->next;
		pos = head->next;
		break;
		break;
	case SEEK_CUR:
	case SEEK_CUR:
		pos = self->first_visible_entry;
		pos = self->top;
		break;
		break;
	case SEEK_END:
	case SEEK_END:
		pos = head->prev;
		pos = head->prev;
@@ -66,7 +66,7 @@ void ui_browser__list_head_seek(struct ui_browser *self, off_t offset, int whenc
			pos = pos->prev;
			pos = pos->prev;
	}
	}


	self->first_visible_entry = pos;
	self->top = pos;
}
}


void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence)
void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence)
@@ -79,7 +79,7 @@ void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence)
		nd = rb_first(root);
		nd = rb_first(root);
		break;
		break;
	case SEEK_CUR:
	case SEEK_CUR:
		nd = self->first_visible_entry;
		nd = self->top;
		break;
		break;
	case SEEK_END:
	case SEEK_END:
		nd = rb_last(root);
		nd = rb_last(root);
@@ -96,7 +96,7 @@ void ui_browser__rb_tree_seek(struct ui_browser *self, off_t offset, int whence)
			nd = rb_prev(nd);
			nd = rb_prev(nd);
	}
	}


	self->first_visible_entry = nd;
	self->top = nd;
}
}


unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self)
unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self)
@@ -104,13 +104,13 @@ unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self)
	struct rb_node *nd;
	struct rb_node *nd;
	int row = 0;
	int row = 0;


	if (self->first_visible_entry == NULL)
	if (self->top == NULL)
                self->first_visible_entry = rb_first(self->entries);
                self->top = rb_first(self->entries);


	nd = self->first_visible_entry;
	nd = self->top;


	while (nd != NULL) {
	while (nd != NULL) {
		SLsmg_gotorc(self->top + row, self->left);
		SLsmg_gotorc(self->y + row, self->x);
		self->write(self, nd, row);
		self->write(self, nd, row);
		if (++row == self->height)
		if (++row == self->height)
			break;
			break;
@@ -122,7 +122,7 @@ unsigned int ui_browser__rb_tree_refresh(struct ui_browser *self)


bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row)
bool ui_browser__is_current_entry(struct ui_browser *self, unsigned row)
{
{
	return (self->first_visible_entry_idx + row) == self->index;
	return self->top_idx + row == self->index;
}
}


void ui_browser__refresh_dimensions(struct ui_browser *self)
void ui_browser__refresh_dimensions(struct ui_browser *self)
@@ -135,13 +135,13 @@ void ui_browser__refresh_dimensions(struct ui_browser *self)
	self->height = rows - 5;
	self->height = rows - 5;
	if (self->height > self->nr_entries)
	if (self->height > self->nr_entries)
		self->height = self->nr_entries;
		self->height = self->nr_entries;
	self->top  = (rows - self->height) / 2;
	self->y  = (rows - self->height) / 2;
	self->left = (cols - self->width) / 2;
	self->x = (cols - self->width) / 2;
}
}


void ui_browser__reset_index(struct ui_browser *self)
void ui_browser__reset_index(struct ui_browser *self)
{
{
	self->index = self->first_visible_entry_idx = 0;
	self->index = self->top_idx = 0;
	self->seek(self, 0, SEEK_SET);
	self->seek(self, 0, SEEK_SET);
}
}


@@ -180,7 +180,7 @@ int ui_browser__refresh(struct ui_browser *self)
	newtScrollbarSet(self->sb, self->index, self->nr_entries - 1);
	newtScrollbarSet(self->sb, self->index, self->nr_entries - 1);
	row = self->refresh(self);
	row = self->refresh(self);
	SLsmg_set_color(HE_COLORSET_NORMAL);
	SLsmg_set_color(HE_COLORSET_NORMAL);
	SLsmg_fill_region(self->top + row, self->left,
	SLsmg_fill_region(self->y + row, self->x,
			  self->height - row, self->width, ' ');
			  self->height - row, self->width, ' ');


	return 0;
	return 0;
@@ -205,8 +205,8 @@ int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es)
			if (self->index == self->nr_entries - 1)
			if (self->index == self->nr_entries - 1)
				break;
				break;
			++self->index;
			++self->index;
			if (self->index == self->first_visible_entry_idx + self->height) {
			if (self->index == self->top_idx + self->height) {
				++self->first_visible_entry_idx;
				++self->top_idx;
				self->seek(self, +1, SEEK_CUR);
				self->seek(self, +1, SEEK_CUR);
			}
			}
			break;
			break;
@@ -214,34 +214,34 @@ int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es)
			if (self->index == 0)
			if (self->index == 0)
				break;
				break;
			--self->index;
			--self->index;
			if (self->index < self->first_visible_entry_idx) {
			if (self->index < self->top_idx) {
				--self->first_visible_entry_idx;
				--self->top_idx;
				self->seek(self, -1, SEEK_CUR);
				self->seek(self, -1, SEEK_CUR);
			}
			}
			break;
			break;
		case NEWT_KEY_PGDN:
		case NEWT_KEY_PGDN:
		case ' ':
		case ' ':
			if (self->first_visible_entry_idx + self->height > self->nr_entries - 1)
			if (self->top_idx + self->height > self->nr_entries - 1)
				break;
				break;


			offset = self->height;
			offset = self->height;
			if (self->index + offset > self->nr_entries - 1)
			if (self->index + offset > self->nr_entries - 1)
				offset = self->nr_entries - 1 - self->index;
				offset = self->nr_entries - 1 - self->index;
			self->index += offset;
			self->index += offset;
			self->first_visible_entry_idx += offset;
			self->top_idx += offset;
			self->seek(self, +offset, SEEK_CUR);
			self->seek(self, +offset, SEEK_CUR);
			break;
			break;
		case NEWT_KEY_PGUP:
		case NEWT_KEY_PGUP:
			if (self->first_visible_entry_idx == 0)
			if (self->top_idx == 0)
				break;
				break;


			if (self->first_visible_entry_idx < self->height)
			if (self->top_idx < self->height)
				offset = self->first_visible_entry_idx;
				offset = self->top_idx;
			else
			else
				offset = self->height;
				offset = self->height;


			self->index -= offset;
			self->index -= offset;
			self->first_visible_entry_idx -= offset;
			self->top_idx -= offset;
			self->seek(self, -offset, SEEK_CUR);
			self->seek(self, -offset, SEEK_CUR);
			break;
			break;
		case NEWT_KEY_HOME:
		case NEWT_KEY_HOME:
@@ -253,7 +253,7 @@ int ui_browser__run(struct ui_browser *self, struct newtExitStruct *es)
				offset = self->nr_entries - 1;
				offset = self->nr_entries - 1;


			self->index = self->nr_entries - 1;
			self->index = self->nr_entries - 1;
			self->first_visible_entry_idx = self->index - offset;
			self->top_idx = self->index - offset;
			self->seek(self, -offset, SEEK_END);
			self->seek(self, -offset, SEEK_END);
			break;
			break;
		default:
		default:
@@ -271,14 +271,13 @@ unsigned int ui_browser__list_head_refresh(struct ui_browser *self)
	struct list_head *head = self->entries;
	struct list_head *head = self->entries;
	int row = 0;
	int row = 0;


	if (self->first_visible_entry == NULL ||
	if (self->top == NULL || self->top == self->entries)
	    self->first_visible_entry == self->entries)
                self->top = head->next;
                self->first_visible_entry = head->next;


	pos = self->first_visible_entry;
	pos = self->top;


	list_for_each_from(pos, head) {
	list_for_each_from(pos, head) {
		SLsmg_gotorc(self->top + row, self->left);
		SLsmg_gotorc(self->y + row, self->x);
		self->write(self, pos, row);
		self->write(self, pos, row);
		if (++row == self->height)
		if (++row == self->height)
			break;
			break;
+3 −3
Original line number Original line Diff line number Diff line
@@ -13,9 +13,9 @@


struct ui_browser {
struct ui_browser {
	newtComponent form, sb;
	newtComponent form, sb;
	u64	      index, first_visible_entry_idx;
	u64	      index, top_idx;
	void	      *first_visible_entry, *entries;
	void	      *top, *entries;
	u16	      top, left, width, height;
	u16	      y, x, width, height;
	void	      *priv;
	void	      *priv;
	unsigned int  (*refresh)(struct ui_browser *self);
	unsigned int  (*refresh)(struct ui_browser *self);
	void	      (*write)(struct ui_browser *self, void *entry, int row);
	void	      (*write)(struct ui_browser *self, void *entry, int row);