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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Java Buffer types versus native arrays: which is faster?

10 点作者 tgymnich超过 4 年前

2 条评论

jariel超过 4 年前
As with everything, it depends.<p>Buffers I believe were created for doing IO operations, wherein you need to move chunks of things around, wherein the underlying net stack needs to fill, flip, copy etc..<p>If you&#x27;re building a video compression library with native components, then Buffers are probably going to help.<p>If you&#x27;re living purely in Javaland memory managed space, then it&#x27;s entirely another question, but know that in the vast majority of cases it won&#x27;t matter.
pestatije超过 4 年前
Try to do a flip and see what happens. Or copy your array to a file, or to a native library. I&#x27;ve never thought of buffers as a replacement for arrays, and I don&#x27;t think they were ever ment to be. The take away from the comparison is basically to do what we were doing already: use native arrays unless doing so with buffers simplifies your code.