mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-15 00:34:08 +09:00
fix: moved findAndCrop to non mutation function (#1700)
This commit is contained in:
@@ -191,14 +191,12 @@ public class ProcessReader: Reader<[TopProcess]> {
|
||||
var processes: [TopProcess] = []
|
||||
output.enumerateLines { (line, _) -> Void in
|
||||
if line.matches("^\\d+ *[^(\\d)]*\\d+\\.*\\d* *$") {
|
||||
var str = line.trimmingCharacters(in: .whitespaces)
|
||||
|
||||
let pidString = str.findAndCrop(pattern: "^\\d+")
|
||||
let usageString = str.findAndCrop(pattern: " +[0-9]+.*[0-9]*$")
|
||||
let command = str.trimmingCharacters(in: .whitespaces)
|
||||
|
||||
let pid = Int(pidString) ?? 0
|
||||
guard let usage = Double(usageString.filter("01234567890.".contains)) else {
|
||||
let str = line.trimmingCharacters(in: .whitespaces)
|
||||
let pidFind = str.findAndCrop(pattern: "^\\d+")
|
||||
let usageFind = pidFind.remain.findAndCrop(pattern: " +[0-9]+.*[0-9]*$")
|
||||
let command = usageFind.remain.trimmingCharacters(in: .whitespaces)
|
||||
let pid = Int(pidFind.cropped) ?? 0
|
||||
guard let usage = Double(usageFind.cropped.filter("01234567890.".contains)) else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user