This seems to be a stupid question since Java does short circuit, but I remembered how Android doesn’t quite use Java in the same sense as I assume, so say in this bit of code I wrote:
... code omitted ...
else if (mimeType.equals("application/x-tar")
|| mimeType.equals("application/x-rar-compressed")
|| mimeType.equals("application/stuffit")
|| mimeType.equals("application/zip")
|| mimeType.equals("application/x-gzip"))
…would it be better for me to put the more common things (zip/rar) before the less common things (tarballs/gzip)?
The fact that I wasn’t able to find a similar question on SO probably gives me the answer to this, but better safe than sorry.
Short circuiting is supported with
||.If you are trying to optimize this case you should try putting each value in a static
Setand then check to see iftypeSet.contains(mimeType).