LINQ声明不是“的foreach”循环更快

编程入门 行业动态 更新时间:2024-10-08 06:21:14
本文介绍了LINQ声明不是“的foreach”循环更快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我写一个网格渲染经理认为这将是一个好主意,把所有使用相同着色器的网格,然后使这些将我在那着色器通。

I am writing a Mesh Rendering manager and thought it would be a good idea to group all of the meshes which use the same shader and then render these will I'm in that shader pass.

我目前使用foreach循环,但不知道是否利用LINQ的可能给我的性能提升?

I am currently using a foreach loop, but wondered if utilising Linq might give me a performance increase?

推荐答案

为什么要LINQ是更快?它还使用循环内部。

Why should LINQ be faster? It also uses loops internally.

大部分的时间,LINQ会有点慢,因为它引入了开销。如果你在意性能,请不要使用LINQ。因为你想更好更短的可读性和可维护性code使用LINQ。

Most of the times, LINQ will be a bit slower because it introduces overhead. Do not use LINQ if you care much about performance. Use LINQ because you want shorter better readable and maintainable code.

更多推荐

LINQ声明不是“的foreach”循环更快

本文发布于:2023-11-29 15:45:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646838.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:更快   声明   LINQ   foreach

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!