iamed2 / ResultTypes.jl

A Result type for Julia—it's like Nullables for Exceptions
Other
95 stars 8 forks source link

make Result immutable so that it doesn't allocate #5

Closed rdeits closed 7 years ago

rdeits commented 7 years ago

(cool talk at JuliaCon today!)

Changing Result from a type to an immutable makes everything faster and prevents allocation (in your benchmark). Specifically, the benchmark from the Readme runs about 2X faster and allocates 0 bytes with this change. As far as I can tell, this is a reasonable thing to do, since I can't think of a situation where a Result should be mutated after creation.

codecov-io commented 7 years ago

Codecov Report

Merging #5 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master     #5   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines          21     21           
=====================================
  Hits           21     21
Impacted Files Coverage Δ
src/ResultTypes.jl 100% <ø> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6d91e6a...1afdea1. Read the comment docs.

iamed2 commented 7 years ago

Superseded by #6 (I gave you credit in the commit)

rdeits commented 7 years ago

Cool, thanks!