ios - Does less space in-between lines of code in Xcode make the build/app faster, or does it not make a difference?
问题描述
As I was formatting my code for a project, specifically regarding uniform spacing (OCD.. hehe). I had a curious thought, does having "too much" (or too little) spacing affect code performance in any way?
I tried searching via docs & Google but was only able to find performance "tips" that were unrelated. I assume any relevant knowledge might involve understanding lower level languages (which I have very little experience). I'll post two simple examples below:
////////// - Lots Of Spacing
func exampleFunctionOne(newText: String) {
if newText.isEmpty {
return
}
exampleLabel.text = newText
return
}
////////// - Little Spacing
func exampleFunctionTwo(newText: String) {
if newText.isEmpty { return }
exampleLabel.text = newText; return
}
Keep in mind, even though these examples are small, my project is currently around 20,000 lines (if that matters).
解决方案
代码格式化一般来说,无论是空格、注释还是其他装饰器都不会影响代码编译后的性能。
随着越来越多的“非代码”字符被添加,项目的编译/构建时间可能会受到负面影响,因为预解析器必须将它们剥离。
推荐阅读
- go - 如何计算int32和int8之和
- microsoft-graph-api - MS Teams Graph API Webhook - 如何在 MS Teams 上订阅聊天消息
- arrays - 在 C 中:如何在函数中传递数据类型结构的数组?
- matlab - 在 Matlab 中,是否可以使用大括号索引连接矩阵?
- linux - 带有流水线的 wsl 命令
- sql - 存储过程不返回结果
- c# - 成功执行所有测试后导致 vstest 挂起的原因
- visual-c++ - COM 客户端代码如何引用类型库中的 IID?
- python - 如何使用 groupby 计算 pandas 数据框中特定列的总数百分比?
- python - 尝试使用 numpy 实现 2d 图像卷积会抛出 ValueError: 操作数不能一起广播