Skip to content

Commit

Permalink
Move optimisation above the callstack
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Jan 12, 2024
1 parent 68a85b9 commit feeef34
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/opuntia.erl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ new(Shape) ->
-spec update(shaper(), tokens()) -> {shaper(), delay()}.
update(none, _TokensNowUsed) ->
{none, 0};
update(Shaper, 0) ->
{Shaper, 0};
update(Shaper, TokensNowUsed) ->
calculate(Shaper, TokensNowUsed, erlang:monotonic_time()).

Expand Down Expand Up @@ -120,8 +122,6 @@ create(#{bucket_size := MaximumTokens,
-spec calculate(shaper(), tokens(), integer()) -> {shaper(), delay()}.
calculate(none, _, _) ->
{none, 0};
calculate(Shaper, 0, _) ->
{Shaper, 0};
calculate(#token_bucket_shaper{shape = {MaximumTokens, Rate, TimeUnit},
available_tokens = LastAvailableTokens,
last_update = NativeLastUpdate,
Expand Down

0 comments on commit feeef34

Please sign in to comment.