TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Optimization tips

38 点作者 clawrencewenham超过 15 年前

3 条评论

messel超过 15 年前
Excellent find and share Clawrence.<p>Worrying too much on the front end about optimization not only inhibits productivity, but results in wasteful optimizing since the majority of our bottlenecks reside in a few key areas. And we may not know or have coded those areas until the project is well under way.
评论 #964494 未加载
solutionyogi超过 15 年前
For the section titled "LINQ? Return expressions, not results", the query returns an 'Iterator'/'Query' and not an 'Expression Tree'. They are completely different things. The underlying point is valid that it makes sense to return the query so that the caller can do perform additional filtering/grouping, if needed.<p>Also, it's great idea to convert query results to List instead of an array. See Eric Lippert's blog on 'Arrays Considered Harmful.' <a href="http://blogs.msdn.com/ericlippert/archive/2008/09/22/arrays-considered-somewhat-harmful.aspx" rel="nofollow">http://blogs.msdn.com/ericlippert/archive/2008/09/22/arrays-...</a><p>Section: Immutable strings? Use String.Format() and StringBuilder<p>For the given example, practically, there is no difference in performance for two code samples. I hate micro optimizations. Use the version which makes the code easier to read.<p>I take serious objection to the tip - 'Minimize the number of variables'. Code readability/maintainability is much more important so use as many variables as you need. Only after you have profiled the code and found that using 3 variables instead of 5 variables gives you performance boost (which I doubt will ever happen), remove those extra variables.
评论 #964491 未加载
tyrmored超过 15 年前
This is why I keep reading Hacker News. Excellent practical advice!