Skip to content

Commit 7914051

Browse files
committed
Optimise dict.is_empty
Closes #808
1 parent ac01429 commit 7914051

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- The performance of `dict.is_empty` has been improved.
6+
37
## v0.54.0 - 2025-02-04
48

59
- The `uri` module gains the `empty` value, representing an empty URI which

src/gleam/dict.gleam

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub fn size(dict: Dict(k, v)) -> Int
5050
/// ```
5151
///
5252
pub fn is_empty(dict: Dict(k, v)) -> Bool {
53-
dict == new()
53+
size(dict) == 0
5454
}
5555

5656
/// Converts the dict to a list of 2-element tuples `#(key, value)`, one for

0 commit comments

Comments
 (0)