HNHacker News
TopNewBestAskShowJobs

evozer

20 karma · joined August 13, 2018

submissionscomments
evozer··on The use of `class` for things that should be simple free functions
There is, it's called static. Just hide it in a .cpp file and expose the real function in a header file.
evozer··on Consistency: How to defeat the purpose of IEEE floating point (2008)
I don't understand your example, why would

(1 + 2.060) - 2.060 == 0

while

1 + (2.060 - 2.060) == 1?

Am I just misunderstanding what you wrote?

evozer··on Let's remove quaternions from every 3D engine (2018)
shouldn't it be e^tau*i = 1 if tau is 2pi?
evozer··on Use mmap with care
Did you consider emulating mmap yourselves?

  "Memory mapped files work by mapping the full file into a virtual address space and then using page faults to determine which chunks to load into physical memory. In essence it allows you to access the file as if you had read the whole thing into memory, without actually doing so."
I feel like this could be done in c++ directly, by maintaining an internal cache for each file that keeps track of which parts of the file are loaded and uses read() to load chunks on demand. Error handling would be a lot simpler (no signals, just a failed read()) and there would be less OS-specific code.
evozer··on Google proposes changes to Chromium which would disable uBlock Origin
I had to go to the last page and click "repeat the search with the omitted results included" to make it show up at all. After doing that it was the third result.
evozer··on Oboe: A C++ library for low latency audio in Android
I looked at the implementation of the openStream() function:

  AudioStream *AudioStreamBuilder::build() {
      AudioStream *stream = nullptr;
      if (mAudioApi == AudioApi::AAudio && isAAudioSupported()) {
          stream = new AudioStreamAAudio(*this);  

      // If unspecified, only use AAudio if recommended.
      } else if (mAudioApi == AudioApi::Unspecified && isAAudioRecommended()) {
          stream = new AudioStreamAAudio(*this);
      } else {
          if (getDirection() == oboe::Direction::Output) {
              stream = new AudioOutputStreamOpenSLES(*this);
          } else if (getDirection() == oboe::Direction::Input) {
              stream = new AudioInputStreamOpenSLES(*this);
          }
      }
      return stream;
  }  

  Result AudioStreamBuilder::openStream(AudioStream **streamPP) {
      if (streamPP == nullptr) {
          return Result::ErrorNull;
      }
      *streamPP = nullptr;
      AudioStream *streamP = build();
      if (streamP == nullptr) {
          return Result::ErrorNull;
      }
      Result result = streamP->open(); // TODO review API
      if (result == Result::OK) {
          *streamPP = streamP;
      }
      return result;
  }
Doesn't this leak memory if streamP->open() fails? I'm also surprised they are using new instead of unique_ptr, especially since one of their listed benefits is "Convenient C++ API (uses the C++11 standard) ".
evozer··on Two Years Ago, India Lacked Fast, Cheap Internet – One Billionaire Changed That
OP said $5 for 84 days though, not a month.
evozer··on Chrome 69: “www.” subdomain missing from URL
Here is the implementation: https://github.com/chromium/chromium/blob/master/components/...
evozer··on OpenAI Five: Goals and Progress
But it would be fun to see NP bodyblock the entire enemy team with one set of treants.
evozer··on How to Write Unmaintainable Code (2017)
If you want to be more efficient, you can also use a union for this.

typedef union { int i; float f; double d; long l; char c; void *p; ... } var;

Now you might also get some nice float-interpreted-as-int bugs if you forget the type!

You can also kind of pretend that you have C#-style type inference:

var x = { .i = 10 }; var y = { .f = 2.0f };