Skip to content

Commit

Permalink
add a note on checking for equality with singletons (#28700)
Browse files Browse the repository at this point in the history
* add a note on checking for equality with singletons
  • Loading branch information
KristofferC authored Aug 17, 2019
1 parent 1fcadf7 commit 19a2b2e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doc/src/manual/performance-tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -1513,3 +1513,11 @@ will not require this degree of programmer annotation to attain performance.
In the mean time, some user-contributed packages like
[FastClosures](https://github.com/c42f/FastClosures.jl) automate the
insertion of `let` statements as in `abmult3`.

# Checking for equality with a singleton

When checking if a value is equal to some singleton it can be
better for performance to check for identicality (`===`) instead of
equality (`==`). The same advice applies to using `!==` over `!=`.
These type of checks frequently occur e.g. when implementing the iteration
protocol and checking if `nothing` is returned from [`iterate`](@ref).

0 comments on commit 19a2b2e

Please sign in to comment.