Skip to content

Commit a914032

Browse files
committed
kconfig: qconf: refactor ConfigInfoView::clicked()
Most of the code in ConfigInfoView::clicked() is unnecessary. There is no need to use the regular expression to search for a symbol. Calling sym_find() is simpler and faster. The hyperlink always begins with the "s" tag, and there is no other tag used. Remove it. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent bce590f commit a914032

File tree

1 file changed

+6
-37
lines changed

1 file changed

+6
-37
lines changed

scripts/kconfig/qconf.cc

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ void ConfigInfoView::menuInfo(void)
10011001
if (sym->name) {
10021002
stream << " (";
10031003
if (showDebug())
1004-
stream << "<a href=\"s" << sym->name << "\">";
1004+
stream << "<a href=\"" << sym->name << "\">";
10051005
stream << print_filter(sym->name);
10061006
if (showDebug())
10071007
stream << "</a>";
@@ -1010,7 +1010,7 @@ void ConfigInfoView::menuInfo(void)
10101010
} else if (sym->name) {
10111011
stream << "<big><b>";
10121012
if (showDebug())
1013-
stream << "<a href=\"s" << sym->name << "\">";
1013+
stream << "<a href=\"" << sym->name << "\">";
10141014
stream << print_filter(sym->name);
10151015
if (showDebug())
10161016
stream << "</a>";
@@ -1124,7 +1124,7 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
11241124
QTextStream *stream = reinterpret_cast<QTextStream *>(data);
11251125

11261126
if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) {
1127-
*stream << "<a href=\"s" << sym->name << "\">";
1127+
*stream << "<a href=\"" << sym->name << "\">";
11281128
*stream << print_filter(str);
11291129
*stream << "</a>";
11301130
} else {
@@ -1134,49 +1134,18 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
11341134

11351135
void ConfigInfoView::clicked(const QUrl &url)
11361136
{
1137-
QByteArray str = url.toEncoded();
1138-
const std::size_t count = str.size();
1139-
char *data = new char[count + 2]; // '$' + '\0'
1140-
struct symbol **result;
1141-
struct menu *m = NULL;
1137+
struct menu *m;
11421138

1143-
if (count < 1) {
1144-
delete[] data;
1145-
return;
1146-
}
1147-
1148-
memcpy(data, str.constData(), count);
1149-
data[count] = '\0';
1150-
1151-
/* Seek for exact match */
1152-
data[0] = '^';
1153-
strcat(data, "$");
1154-
result = sym_re_search(data);
1155-
if (!result) {
1156-
delete[] data;
1157-
return;
1158-
}
1159-
1160-
sym = *result;
1161-
1162-
/* Seek for the menu which holds the symbol */
1163-
for (struct property *prop = sym->prop; prop; prop = prop->next) {
1164-
if (prop->type != P_PROMPT && prop->type != P_MENU)
1165-
continue;
1166-
m = prop->menu;
1167-
break;
1168-
}
1139+
sym = sym_find(url.toEncoded().constData());
11691140

1141+
m = sym_get_prompt_menu(sym);
11701142
if (!m) {
11711143
/* Symbol is not visible as a menu */
11721144
symbolInfo();
11731145
emit showDebugChanged(true);
11741146
} else {
11751147
emit menuSelected(m);
11761148
}
1177-
1178-
free(result);
1179-
delete[] data;
11801149
}
11811150

11821151
void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)

0 commit comments

Comments
 (0)