Android Question Passing Views

epiCode

Active Member
Licensed User
In the following two scenarios:

B4X:
....
processData (bv as view,..........)
....

private sub processData(bv as view,....)
.....
bv.add(somepanel,......)
end sub


AND

B4X:
....
somepanel = processData (some params..........)
bv.add ( somepanel, .......)
....

private sub processData(some params....) as somepanel
.....
return somepanel
end sub

my queries are
1. which of these codes will be faster (assuming that processdata is called a lot of times during CLV loading)
2. will having many parameters passed through call reduce performance or it will be barely noticeable ?

Thanks
 
Solution
While I appreciate what you want to convey here, this is stemming from the fact that when I'm passing whole lot parameters to reduce duplication of code it is actually slowing down CLV loading a lot
No it doesn't. You can pass million views and it will be extremely fast.

1. Make sure to test performance in release mode.
2. If something is slow, it is unrelated to the views passed. When you pass a view, you are not making a copy of any object. It is a simple pointer that is passed.

epiCode

Active Member
Licensed User
You are over thinking things. Premature optimisation is the enemy of good code. Just write the code it in a straightforward and understandable way and see if it is good enough.
While I appreciate what you want to convey here, this is stemming from the fact that when I'm passing whole lot parameters to reduce duplication of code it is actually slowing down CLV loading a lot - If I don't I am getting into unwanted initialization issues. Hence seeking advice before I waste more time restructuring code.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
While I appreciate what you want to convey here, this is stemming from the fact that when I'm passing whole lot parameters to reduce duplication of code it is actually slowing down CLV loading a lot
No it doesn't. You can pass million views and it will be extremely fast.

1. Make sure to test performance in release mode.
2. If something is slow, it is unrelated to the views passed. When you pass a view, you are not making a copy of any object. It is a simple pointer that is passed.
 
Upvote 1
Solution

epiCode

Active Member
Licensed User
No it doesn't. You can pass million views and it will be extremely fast.

1. Make sure to test performance in release mode.
2. If something is slow, it is unrelated to the views passed. When you pass a view, you are not making a copy of any object. It is a simple pointer that is passed.
Thanks Erel - That clarifies that the slowdown issue has to be something in my code itself and not where the view related transactions happen.
 
Upvote 0
Top