Skip to content

Commit

Permalink
reduce amount allocation for single number decode (#65)
Browse files Browse the repository at this point in the history
* reduce amount allocation for single number decode

Signed-off-by: Joseph Petersen <josephp90@gmail.com>

* fix issue with guarded ids

* add optimized splitter

* Make split private

* use splitter for multiple numbers

* Remove MultipleResultsException

As this can never happen without checking for separators.

* fix if condition check for number

* allocation free GenerateHashFrom

* Reduce allocation further for Encode

* fix return empty string

* fix number length

* Remove reference to multiple results exception
  • Loading branch information
jetersen committed May 22, 2022
1 parent eb3ca5b commit 480cabe
Show file tree
Hide file tree
Showing 6 changed files with 300 additions and 64 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ try
number = hashids.DecodeSingle("NkK9");
}
catch (NoResultException) { // Decoding the provided hash has not yielded any result. }
catch (MultipleResultsException) { // The decoding process yielded more than one result when just one was expected. }
```

`number` is now going to be:
Expand Down Expand Up @@ -143,7 +142,6 @@ try
number = hashids.DecodeSingleLong("KVO9yy1oO5j");
}
catch (NoResultException) { // Decoding the provided hash has not yielded any result. }
catch (MultipleResultsException) { // The decoding process yielded more than one result when just one was expected. }
```

`number` is now going to be:
Expand Down

0 comments on commit 480cabe

Please sign in to comment.