Skip to content

Commit 5b6d99b

Browse files
authored
Refactor data definition (#29)
This should make it easier to contribute without having to modify so many lines. Closes GH-27
1 parent edaa1d8 commit 5b6d99b

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

src/stats.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,17 @@ char *screenfetch() {
126126
return extract_named_version(out, "screenFetch - Version ");
127127
}
128128

129-
void get_stats(FetchStat stats[STATS_SIZE]) {
130-
stats[0].label = "Fastfetch";
131-
stats[0].version = fastfetch();
132-
stats[1].label = "fetchfetch";
133-
stats[1].version = version;
134-
stats[2].label = "hyfetch";
135-
stats[2].version = hyfetch();
136-
stats[3].label = "Neofetch";
137-
stats[3].version = neofetch();
138-
stats[4].label = "onefetch";
139-
stats[4].version = onefetch();
140-
stats[5].label = "pfetch";
141-
stats[5].version = pfetch();
142-
stats[6].label = "UwUfetch";
143-
stats[6].version = uwufetch();
144-
stats[7].label = "screenFetch";
145-
stats[7].version = screenfetch();
129+
void get_stats(FetchStat stats[static STATS_SIZE]) {
130+
const FetchStat data[STATS_SIZE] = {
131+
{.label = "Fastfetch", .version = fastfetch()},
132+
{.label = "fetchfetch", .version = version},
133+
{.label = "hyfetch", .version = hyfetch()},
134+
{.label = "Neofetch", .version = neofetch()},
135+
{.label = "onefetch", .version = onefetch()},
136+
{.label = "pfetch", .version = pfetch()},
137+
{.label = "UwUfetch", .version = uwufetch()},
138+
{.label = "screenFetch", .version = screenfetch()},
139+
};
140+
141+
memcpy(stats, data, sizeof data);
146142
}

0 commit comments

Comments
 (0)