Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#43 modern c++ for c programmers part 4 #127

Merged

Conversation

kele1997
Copy link
Member

@kele1997 kele1997 commented Nov 19, 2018

(提交翻译请使用下面的模板,其他类型pr请删除)

closes #43

1.译者信息

(请大家一定要填伯乐在线个人主页这一项,方便署名,🙏)

伯乐在线个人主页 新浪微博
http://www.jobbole.com/members/q3057027161/ https://weibo.com/fxk1997

2.疑问区

(可在此区域列举有疑问的语句,提示校对人员重点关注)

3.自查表

  • 确认pr的目标分支是trans分支
  • 确认pr不包含除译文以外的文件
  • 补充评论区closes关键字以关联对应issue
  • 通读文章,确保读者(非译者)能够理解文章内容(语言性,非技术性)
  • 通读文章,确保语句通顺(有疑问语句请在疑问区提出)
  • 符合排版规范要求

4.发布信息(译者无需填写)

发布链接:


@hanxiaomax

@ghost ghost assigned kele1997 Nov 19, 2018
@ghost ghost added the B3-Need review 完成翻译待校对,请至对应的pr认领校对并添加校对中标签 label Nov 19, 2018
@hanxiaomax hanxiaomax self-requested a review November 19, 2018 12:35
@hanxiaomax hanxiaomax added B4-Reviewing 文章正在校对中,完成后评论合入主线并添加C1 and removed B3-Need review 完成翻译待校对,请至对应的pr认领校对并添加校对中标签 labels Nov 19, 2018
Copy link
Member

@hanxiaomax hanxiaomax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

小问题我直接修改

```

Although lambdas are, in essence, syntactical sugar, their availability has made modern C++ a far more expressive language. In addition, as noted in [part 1](https://ds9a.nl/articles/posts/c++-1/), passing code snippets as function pointers severely restricts what the compiler can do to optimize code. So not only do lambdas lead to fewer lines of code, the resulting binaries can be faster too.
虽然 lambda 表达式本质上是语法糖,但他们的易用性使现代 C++ 成为一种更具表达力的语言。此外,正如 [第一部分](https://ds9a.nl/articles/posts/c++-1/) 所说,将代码片段以函数指针传递会严重制约编译器优化代码的能力。因此 lambda 表达式不仅可以减少代码的行数,而且可以提高应用程序的运行速度。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

它们

使用这样的代码,我们保存一些 const (只读)的指针,这些指针指向无序 map `allWords` 的键值(key)。然后我们对 `optrwords` 进行排序,`optrwords` 中包含的全是指针,因此在排序中 lambda 表达式中我们进行了解引用。

If we index the Linux source tree, which contains around 600,000 unique words, this does save us around 14 megabytes of memory, which is nice.
如果我们建立了 Linux 源代码索引树,这棵树会包含大约 600,000 个互不相同的单词,这大概需要占用 14 兆字节的内存,这已经很棒了。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

帮我们节省了14m的空间

@ghost ghost assigned hanxiaomax Nov 20, 2018
@hanxiaomax hanxiaomax added C1-Finished 校对完成,待发布 and removed B4-Reviewing 文章正在校对中,完成后评论合入主线并添加C1 labels Nov 20, 2018
@hanxiaomax hanxiaomax merged commit 410cd74 into jobbole:trans Nov 20, 2018
@hanxiaomax
Copy link
Member

认领校对

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C1-Finished 校对完成,待发布
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MODERN C++ FOR C PROGRAMMERS: PART 4
2 participants