TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

102 pointsby vs2over 8 years ago

13 comments

Arkanosisover 8 years ago
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>)
TeMPOraLover 8 years ago
&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 未加载
saurikover 8 years ago
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 未加载
marcomsover 8 years ago
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 未加载
Kretiiniover 8 years ago
Stupid question: why not unsigned int?
评论 #13660054 未加载
评论 #13659653 未加载
评论 #13659342 未加载
zevebover 8 years ago
&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.
andrewprockover 8 years ago
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 未加载
grabcocqueover 8 years ago
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
rwmjover 8 years ago
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.
mjsover 8 years ago
So has Linus learnt another editor, as threatened??
评论 #13659005 未加载
xookover 8 years ago
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.
ameliusover 8 years ago
Well, it is called MicroEmacs for a reason ...
tomtoiseover 8 years ago
Original Title, for Posterity:<p>&quot;Linus has been polishing a turd for two years&quot;
评论 #13659079 未加载