07-28-2021 01:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-28-2021 01:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
SDK:5.0.2
Device: Fitbit Versa3(36.128.5.38)
What does it do internally when I write code like below?
if (foo) {
aGraphicsElement.x += 10;
}
When foo is true, Will the rendering invoke twice? Or, combine into once?
Is it be better to write like below?
if (foo) {
x += 10;
}
aGraphicsElement.x = x;
Answered! Go to the Best Answer.

- Labels:
-
JavaScript
Accepted Solutions
07-28-2021 01:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


07-28-2021 01:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
I think the latter could be more efficient, because changing an element's x might result in the layout being recalculated each time. (Maybe it doesn't, if layouts are only recalculated after all of your code has finished.)
Although it's probably not what you want to do, you could write aGraphicsElement.x = foo? 20 : 10;
Gondwana Software
07-28-2021 01:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


07-28-2021 01:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
I think the latter could be more efficient, because changing an element's x might result in the layout being recalculated each time. (Maybe it doesn't, if layouts are only recalculated after all of your code has finished.)
Although it's probably not what you want to do, you could write aGraphicsElement.x = foo? 20 : 10;
Gondwana Software
07-28-2021 02:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-28-2021 02:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Gondwana
Thank you for your replay.
I think same thing.
I've been plotting to cut corners. But I' ll write right way.

