Stable ids for (source file, function name), in order of first appearance. Several profile names can be one function: a static inline of a header is recorded once per file that includes it.
| 111 | |
| 112 | |
| 113 | class Functions: |
| 114 | """Stable ids for (source file, function name), in order of first |
| 115 | appearance. Several profile names can be one function: a static inline of a |
| 116 | header is recorded once per file that includes it.""" |
| 117 | |
| 118 | def __init__(self, table): |
| 119 | self.table = table |
| 120 | self.ids = {} |
| 121 | |
| 122 | def key(self, name): |
| 123 | if name in self.table: |
| 124 | return self.table[name] |
| 125 | # Not in the coverage mapping: keep what the profile says, the |
| 126 | # translation unit for a function with internal linkage. |
| 127 | source, _, short = name.rpartition(":") |
| 128 | return (source, short) |
| 129 | |
| 130 | def ids_of(self, names): |
| 131 | out = set() |
| 132 | for name in names: |
| 133 | key = self.key(name) |
| 134 | if key not in self.ids: |
| 135 | self.ids[key] = len(self.ids) |
| 136 | out.add(self.ids[key]) |
| 137 | return sorted(out) |
| 138 | |
| 139 | def rows(self): |
| 140 | for (source, short), ident in sorted(self.ids.items(), key=lambda item: item[1]): |
| 141 | yield ident, source, short |
| 142 | |
| 143 | |
| 144 | def reduce_suite(suite, suite_dir, profdata, suite_ok): |