Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kconfig: cache expression values

Cache expression values to avoid recalculating them repeatedly.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+39 -4
+2
scripts/kconfig/confdata.c
··· 396 396 } 397 397 } 398 398 399 + expr_invalidate_all(); 400 + 399 401 while (getline_stripped(&line, &line_asize, in) != -1) { 400 402 struct menu *choice; 401 403
+30 -4
scripts/kconfig/expr.c
··· 887 887 ? kind : k_string; 888 888 } 889 889 890 - tristate expr_calc_value(struct expr *e) 890 + static tristate __expr_calc_value(struct expr *e) 891 891 { 892 892 tristate val1, val2; 893 893 const char *str1, *str2; 894 894 enum string_value_kind k1 = k_string, k2 = k_string; 895 895 union string_value lval = {}, rval = {}; 896 896 int res; 897 - 898 - if (!e) 899 - return yes; 900 897 901 898 switch (e->type) { 902 899 case E_SYMBOL: ··· 956 959 printf("expr_calc_value: relation %d?\n", e->type); 957 960 return no; 958 961 } 962 + } 963 + 964 + /** 965 + * expr_calc_value - return the tristate value of the given expression 966 + * @e: expression 967 + * return: tristate value of the expression 968 + */ 969 + tristate expr_calc_value(struct expr *e) 970 + { 971 + if (!e) 972 + return yes; 973 + 974 + if (!e->val_is_valid) { 975 + e->val = __expr_calc_value(e); 976 + e->val_is_valid = true; 977 + } 978 + 979 + return e->val; 980 + } 981 + 982 + /** 983 + * expr_invalidate_all - invalidate all cached expression values 984 + */ 985 + void expr_invalidate_all(void) 986 + { 987 + struct expr *e; 988 + 989 + hash_for_each(expr_hashtable, e, node) 990 + e->val_is_valid = false; 959 991 } 960 992 961 993 static int expr_compare_type(enum expr_type t1, enum expr_type t2)
+4
scripts/kconfig/expr.h
··· 39 39 * 40 40 * @node: link node for the hash table 41 41 * @type: expressoin type 42 + * @val: calculated tristate value 43 + * @val_is_valid: indicate whether the value is valid 42 44 * @left: left node 43 45 * @right: right node 44 46 */ 45 47 struct expr { 46 48 struct hlist_node node; 47 49 enum expr_type type; 50 + tristate val; 51 + bool val_is_valid; 48 52 union expr_data left, right; 49 53 }; 50 54
+2
scripts/kconfig/internal.h
··· 15 15 16 16 extern HASHTABLE_DECLARE(expr_hashtable, EXPR_HASHSIZE); 17 17 18 + void expr_invalidate_all(void); 19 + 18 20 struct menu; 19 21 20 22 extern struct menu *current_menu, *current_entry;
+1
scripts/kconfig/symbol.c
··· 519 519 520 520 for_all_symbols(sym) 521 521 sym->flags &= ~SYMBOL_VALID; 522 + expr_invalidate_all(); 522 523 conf_set_changed(true); 523 524 sym_calc_value(modules_sym); 524 525 }