fadden, thanks for your reply.

i'm curious as to why the android devs only used switch statements
then, if, as you say, an if statement would have been more efficient..
hmm..

anyway, thank you!
asymmetric

On Apr 28, 10:37 pm, fadden <[email protected]> wrote:
> On Apr 28, 4:33 am, asymmetric <[email protected]> wrote:
>
> > by looking at the Notepad examples, i've noticed that the switch
> > statement is used even when there's only one case handled, as in:
> [...]
> > my question is, which is the most efficient statement? are there any
> > noticeable differences, enough to justify a refactoring?
>
> For a single element, an "if" statement will be faster and more
> compact.
>
> Unless you're calling it thousands of times per second, it's not going
> to make a difference in performance.  It's probably using about 20
> more bytes of Dalvik bytecode than the equivalent "if", so unless you
> have a bunch of them the size won't matter either.
>
> Having all of the code look roughly the same may make it easier to
> understand and maintain.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to