Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/Resources/CPU.vala
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,18 @@ public class Monitor.CPU : Object {
dis = new DataInputStream (csv_file.read ());
string flag_data;
while ((flag_data = dis.read_line ()) != null) {
var splitted = flag_data.split (",");
all_flags.set (splitted[0], splitted[1].replace ("\r", ""));

int comma_position = flag_data.index_of_char (',');

if (comma_position == -1) break; // quick exit if no commas are in the line

string key = flag_data.substring (0, comma_position);
string value = flag_data.substring (comma_position + 1)
.replace ("\"", "")
.replace (" ", " ")
.strip ();

all_flags.set (key, value.replace ("\r", ""));
}
debug ("Parsed file %s", csv_file.get_path ());

Expand Down