持有人模式接近差异和性能比较

发布于 2024-12-04 20:11:05 字数 636 浏览 1 评论 0原文

我见过两种方法做同样的事情,我不知道什么更快,什么更好,以及有什么区别。 。 。

我的意思是只有这几行是不同的,其他一切都是一样的,但仍然有两种方法,我不明白有什么不同,哪种方法更快

案例一:

public View getView(int position, View convertView,ViewGroup parent) {
    View row=super.getView(position, convertView, parent);
    ViewHolder holder=(ViewHolder)row.getTag();

情况二:

public View getView(int position, View convertView,ViewGroup parent) {
        //of course some checks if the convertView is null, but that is not the point
    ViewHolder holder=(ViewHolder)convertView.getTag();

还有一个子问题:- ) 我如何测试哪个更快?我的意思是我应该如何测试适配器的性能?

谢谢

I have seen two ways of doing the same thing, and I do not know what is faster and what is better , and what is the difference . . .

I mean only this few row at the begging are differences and everything else is the same, but still there are two approaches and I do not understand what is different and which way is faster

case one:

public View getView(int position, View convertView,ViewGroup parent) {
    View row=super.getView(position, convertView, parent);
    ViewHolder holder=(ViewHolder)row.getTag();

case two:

public View getView(int position, View convertView,ViewGroup parent) {
        //of course some checks if the convertView is null, but that is not the point
    ViewHolder holder=(ViewHolder)convertView.getTag();

one more sub-question :-)
How can I test what is faster ? I mean how should I do testing for performance on adapters ?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倥絔 2024-12-11 20:11:05

我不明白有什么不同以及哪种方式更快

不同的是,第一个方法链接到超类,而第二个方法则不是。

如何测试更快?我的意思是我应该如何测试适配器的性能?

使用 Traceview

I do not understand what is different and which way is faster

What is different is that the first one is chaining to the superclass, and the second one is not.

How can I test what is faster ? I mean how should I do testing for performance on adapters ?

Use Traceview.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文