删除不必要的命名空间(使用)指令是否有性能提升? [英] Is there a performance gain in removing unnecessary namespace (using) directives?

查看:24
本文介绍了删除不必要的命名空间(使用)指令是否有性能提升?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的类中有多少使用编译器指令是否重要?删除那些不必要的是否有性能提升?

Does it matter how many using compiler directives are in my classes? Is there a performance gain in removing those that aren't necessary?

虽然我喜欢编写精简的代码,但有时代码段会被修改,并且没有机会回去检查所有包含的命名空间是否真的有必要.或者,我不会返回并删除那些由 Visual Studio 自动插入的内容.

Although I enjoy writing streamlined code, on occasion, code segments get modified, and don't have the opportunity to go back and check to see if all of the included namespaces are really necessary. Or, I don't go back and remove those that are auto-inserted by visual studio.

即:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

谢谢!

推荐答案

不,没有性能优势.

编译器不会为 using 语句生成 IL(可执行代码).IL 仅针对那些利用您提供的 using 语句的类、方法调用等生成.

The compiler doesn't generate IL (executable code) for using statements. IL is only generated for those classes, method calls, etc. that take advantage of the using statements you provide.

因此,未使用的 using 语句的唯一影响可能是略微增加您的构建时间,或者在您想知道他们为什么在那里之后让下一个开发人员.

Consequently, the only effect unused using statements might have is to slightly increase your build time, or make the next developer after you wonder why they are there.

这篇关于删除不必要的命名空间(使用)指令是否有性能提升?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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