Skip to content

Commit

Permalink
performance improvements & more
Browse files Browse the repository at this point in the history
`processes` keys and "proc_pid" item of each `rv.data` item are no longer a str but the int it should be.
No need for converting each pid to string on each `update_processes` call.

For same reasons, "proc_cpu" and "proc_mem" items of each `rv.data` are no longer str but float.
So now, `main.key_func` do not have to convert and change strings in each call. The string used by GUI is just derived from the real value, instead of being stored like that

`process_iter` calls no longer ask for "pid", as it is always stored in a class variable. So `proc.info["pid"]` is now `proc.pid`.

On `update_processes` there was two iterations over the results of `process_iter`, now is just a faster one.

In the same function the selection label was being updated wrongly. Just the first selection control found with the inexistent pid would be deleted, including an entire search. Now it calls the same as if the checkbox was unmarked.

For first ordering, `order` was being called to set `key_func`, `order_by` and `reverse`. Now its made on `__init__`

`correct_special_order_cell` and `correct_order_cell` had a assign of a modified dict into the "old dict", but the modified dict is just a shallow copy, so the assign was not needed at all

Old `existent_search` is the same as checking for `search` bcs for Python empty strings return False

`fast_search` and other methods which need to put Threads in lists were appending and then accessing the last element. Now they set a local variable, append the local variable and keep with acess to the Thread without entering the list.

`fast_search` and `select_row` were considering a no lowercased text

Repeat of same iteration to find variables and methods in `set_visible_range` solved

`sorted_by` variable was not being used

`title` local variable of `show_fails` now more readable (and maybe faster)

unneed `not` operator in two ìf else` at main.kv removed

:face_with_head_bandage:
  • Loading branch information
ntaraujo committed Mar 24, 2021
1 parent 9539a65 commit 99bfa86
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 86 deletions.
12 changes: 6 additions & 6 deletions src/main.kv
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
MDTextField:
id: search_field
hint_text: 'Search process'
on_text: root.fast_answer(self.text)
on_text: root.fast_answer(self.text.lower())
MDIconButton:
icon: 'menu'
on_release: app.navigator.ids.nav_drawer.set_state("open")
Expand Down Expand Up @@ -121,20 +121,20 @@
MDLabel:
size_hint_x: None
width: "48dp"
text: root.proc_pid
text: str(root.proc_pid)
color: app.theme_cls.opposite_bg_normal
font_style: app.proc_style
MDLabel:
text: root.proc_name
color: app.theme_cls.opposite_bg_normal
font_style: app.proc_style
MDLabel:
text: root.proc_cpu
text: "{:.4f}%".format(root.proc_cpu)
halign: "center"
color: app.theme_cls.opposite_bg_normal
font_style: app.proc_style
MDLabel:
text: root.proc_mem
text: "{:.4f}%".format(root.proc_mem)
halign: "center"
color: app.theme_cls.opposite_bg_normal
font_style: app.proc_style
Expand Down Expand Up @@ -175,7 +175,7 @@
MDLabel:
text: root.proc_user
halign: "center"
font_size: root.little_font if root.little_font is not None else self.font_size
font_size: self.font_size if root.little_font is None else root.little_font
color: app.theme_cls.opposite_bg_normal

<Container@IRightBodyTouch+MDBoxLayout>
Expand Down Expand Up @@ -231,7 +231,7 @@
color: app.theme_cls.opposite_bg_normal
on_ref_press: web_open(self.href)
MDIconButton:
icon: 'moon-waxing-crescent' if not app.dark else 'white-balance-sunny'
icon: 'white-balance-sunny' if app.dark else 'moon-waxing-crescent'
on_release: app.dark = not app.dark

<CheckZoom@MDCheckbox>:
Expand Down
Loading

0 comments on commit 99bfa86

Please sign in to comment.