SmartCookieWeb icon indicating copy to clipboard operation
SmartCookieWeb copied to clipboard

[Feature] Micro-optimizations

Open PapiGelvez opened this issue 1 year ago • 0 comments

Hi, I'm a Uni student and I did a micro-optimization analysis of your app for a class. I identified some simple things that could improve the app's performance (memory usage or disk space). Clearly, these micro-optimizations could not be correct or not align with your team's design decisions, so I ask you to be critical of them. Thank you in advance

Replace the usage of findViewById() to the usage of binding instead.

Every single layout element uses that function to be accessed, a simple change could be to use binding. This is an example for TabViewHolder.kt elements (line 24):

private var binding = LayoutBinding private val txtTitle = binding.textTab

Use icons with transparent backgrounds

This would reduce overdrawing and GPU performance issues

There are some variables that are never used

This would reduce memory space used. An example can be found in BrowserActivity.kt (lines 155-156)

Use Constraint/Relative layouts with more frequency

There are nested Linear layouts which could hinder rendering performance

Use more indexed loops instead of forEach loops

I think this one varies depending on code and needs to be measured. But an example can be seen in SmartCookieWebClient.kt (lines 487-489), where an indexed loop is used

Other micro-optimizations

More usage of Weak References to avoid memory leaks Reviewing unused resources like images Reviewing if there is the possibility of implementing more memory-friendly data structures like ArrayMap or SparseArray

PapiGelvez avatar Nov 25 '24 07:11 PapiGelvez