Skip to content

Commit ffee7df

Browse files
committed
Use ok_or_else for lazy error logging in DNS resolution
Optimizes the DNS resolver setup by deferring log execution until an actual failure occurs. Changes: - Replaced `ok_or` with `ok_or_else` when resolving DNS server addresses. evaluation and unnecessary string formatting on successful builds. This ensures that logging overhead and string interpolation are only incurred during error states, rather than being evaluated on every successful initialization.
1 parent 403ced3 commit ffee7df

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ fn build_with_store_internal(
17571757
.to_socket_addrs()
17581758
.map_err(|_| BuildError::DNSResolverSetupFailed)?
17591759
.next()
1760-
.ok_or({
1760+
.ok_or_else(|| {
17611761
log_error!(logger, "No valid address found for: {}", dns_server_address);
17621762
BuildError::DNSResolverSetupFailed
17631763
})?;

0 commit comments

Comments
 (0)