为什么反射放缓Android手机 [英] why does reflection slow down android phone

查看:175
本文介绍了为什么反射放缓Android手机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了很多次,反射会拖慢手机性能。
如何真正是这样吗?

I read many times that reflection will slow down the phone performance. How true is this?

例如在我的情况,我从一个Web服务的一些参数,具有相同的名称作为一类我在我的Andr​​oid应用程序的参数。所以我只设置使用Java字段和反思这些参数的值......这似乎并没有表现慢下来。

For example in my case, I get some parameters from a web service which have the same name as the parameters of a class I have in my android app. so I just set the values of these parameters using java fields and reflection... it doesn't seem to slow down the performance..

任何人可以向我解释这背后的想法有关反射降低系统性能的事实?

can anybody explain to me the fact behind this idea about reflection slowing down performance?

推荐答案

这个问题。基本上,你是因为反射发生动态获取,编译器可以执行优化之外。

Take a look at this question. Basically, you are getting outside of the optimizations that the compiler can perform because reflection happens dynamically.

如果你不是做了很多反思电话(例如,那就要烂ListView的getView里面做),你也许可以逃脱它。它的存在,使用,仅仅是明智了。

If you're not making a lot of reflection calls (e.g., it would be bad to do inside the getView of a ListView), you can probably get away with it. It's there to be used, just be judicious about it.

这篇关于为什么反射放缓Android手机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆