更新时间:2022-05-31 20:32:16
可以分析性能.尽管在这种项目很少的情况下,您可能需要运行代码数百万次才能真正获得有价值的差异.
Performance can be profiled. Though in this case of so few items, you may need to run the code millions of times to actually get worthwhile differences.
我会这样说:Queue<T>
会更明确地暴露你的 intent,人们知道队列是如何工作的.
I will say this: Queue<T>
will expose your intent more explicitly, people know how a queue works.
像队列一样使用的列表不是很清楚,尤其是当您有很多不必要的索引和 RemoveAt(magicNumber)
代码时.从代码维护的角度来看,Dequeue
更具消耗性.
A list being used like a queue is not as clear, especially if you have a lot of needless indexing and RemoveAt(magicNumber)
code. Dequeue
is a lot more consumable from a code maintenance point of view.
如果这会给您带来可衡量的性能问题,您可以解决它.不要预先解决所有潜在性能问题.
If this then gives you measurable performance issues, you can address it. Don't address every potential performance issue upfront.