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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Stop using 'short' for line and allocation sizes (2013)

102 点作者 vs2超过 8 年前

13 条评论

Arkanosis超过 8 年前
And then: “Don&#x27;t use &#x27;char&#x27; for number of lines” (2014: <a href="https:&#x2F;&#x2F;git.kernel.org&#x2F;cgit&#x2F;editors&#x2F;uemacs&#x2F;uemacs.git&#x2F;commit&#x2F;?id=8841922689769960fa074fbb053cb8507f2f3ed9" rel="nofollow">https:&#x2F;&#x2F;git.kernel.org&#x2F;cgit&#x2F;editors&#x2F;uemacs&#x2F;uemacs.git&#x2F;commit...</a>)
TeMPOraL超过 8 年前
&quot;32,767 characters in a line should be enough for anyone.&quot;<p>I guess there&#x27;s one constant with humans and infrastructure - people will always find ways to hit its limits.
评论 #13658917 未加载
saurik超过 8 年前
This is actually an unfortunate patch... it rearranged lines for no particular reason, and scrambled the comments without updating them: they were multi-line sentences and referenced each other&#x27;s positions.<p>The original code:<p><pre><code> struct line *b_dotp; &#x2F;* Link to &quot;.&quot; struct line structure *&#x2F; short b_doto; &#x2F;* Offset of &quot;.&quot; in above struct line *&#x2F; struct line *b_markp; &#x2F;* The same as the above two, *&#x2F; short b_marko; &#x2F;* but for the &quot;mark&quot; *&#x2F; struct line *b_linep; &#x2F;* Link to the header struct line *&#x2F; </code></pre> The new code:<p><pre><code> struct line *b_dotp; &#x2F;* Link to &quot;.&quot; struct line structure *&#x2F; struct line *b_markp; &#x2F;* The same as the above two, *&#x2F; struct line *b_linep; &#x2F;* Link to the header struct line *&#x2F; int b_doto; &#x2F;* Offset of &quot;.&quot; in above struct line *&#x2F; int b_marko; &#x2F;* but for the &quot;mark&quot; *&#x2F; int b_mode; &#x2F;* editor mode of this buffer *&#x2F;</code></pre>
评论 #13663577 未加载
marcoms超过 8 年前
Why not fixed-size ints - uint8_t, etc. from stdint.h? I&#x27;ve not been using C for a while, so I wonder what the viewpoints are regarding this.
评论 #13659952 未加载
评论 #13659842 未加载
评论 #13660051 未加载
评论 #13660014 未加载
Kretiini超过 8 年前
Stupid question: why not unsigned int?
评论 #13660054 未加载
评论 #13659653 未加载
评论 #13659342 未加载
zeveb超过 8 年前
&gt; And if you have a line that is longer than 2GB, you only have yourself to blame.<p>This is why I like languages like Lisp: by default, integers are only limited by the amount of memory available (as an example: (- (expt 2 1024) (expt 3 27)) → 179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356321998626652229).<p>For efficiency one can of course limit things to fixnums, and in a kernel one would want to be careful not to let reading a file eat all memory — but that&#x27;s all doable in a Lisp.
andrewprock超过 8 年前
For structs where there are only a dozen or so in memory at any one time, this makes sense.<p>For structs where there are thousands, or millions, in memory using the smallest type required to get the job done will improve performance because you will fit more data into the cache.
评论 #13660398 未加载
grabcocque超过 8 年前
I wonder if uemacs is now that rarest of beasts, a piece of software that is actually _done_.<p>Edit: apparently it has no undo. The rules:<p>1) Linus does not make mistakes<p>2) In the event of Linus making a mistake, see rule 1<p>3) ...<p>4) git reset --hard HEAD
rwmj超过 8 年前
This reminds me of my first job (in ECAD&#x2F;EDA) where microemacs was part of the design process. We had microemacs &quot;programs&quot; (like macros) which post-processed the output from other CAD tools. Microemacs had an internal C-like (interpreted) language, and combined with the fact that it ran on DOS and Windows 3.1 made it sort of suitable for this. However I really hope those have been replaced now.
mjs超过 8 年前
So has Linus learnt another editor, as threatened??
评论 #13659005 未加载
xook超过 8 年前
It was astounding to me when I watched that talk and he mentioned this issue. Part of me still hopes he uses this same editor.
amelius超过 8 年前
Well, it is called MicroEmacs for a reason ...
tomtoise超过 8 年前
Original Title, for Posterity:<p>&quot;Linus has been polishing a turd for two years&quot;
评论 #13659079 未加载