使用NSMutableDictionary与NSMutableArray产生的性能损失> [英] Performance hit incurred using NSMutableDictionary vs. NSMutableArray>

查看:168
本文介绍了使用NSMutableDictionary与NSMutableArray产生的性能损失>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑使用NSMutableDictionary代替我当前的NSMutableArray。这主要是因为KVC / KVO的原因。该集合将在我的绘制方法的内循环中经历重度突变。

I am considering using an NSMutableDictionary in place of my current NSMutableArray. This is primarily for KVC/KVO reasons. The collection will undergo heavy mutation within the inner loop of my drawing method. Can I expect to incur a significant performance hit if I go ahead with this replacement?

干杯,
Doug

Cheers, Doug

推荐答案

确定的唯一方法是测量。我们没有足够的知识关于NSMutableDictionary和NSMutableArray的实现如何工作,所以没有什么问题。

The only way to be sure is to measure. None of us have enough knowledge about how NSMutableDictionary's and NSMutableArray's implementations work, so there's little point asking.

授予,你可能希望一些命中,因为字典必须做额外散列一个简单的数组不会。是否很重要。

Granted, you could probably expect some hit since the dictionary has to do additional hashing that a simple array would not. Whether or not that is "significant" is hard to say.

再次,测量

这篇关于使用NSMutableDictionary与NSMutableArray产生的性能损失>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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