[PR #2092] [MERGED] Fix initial vec capacity in NameServerConfigGroup::from_ips_clear #2801

Closed
opened 2026-03-16 11:09:00 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/2092
Author: @silverlyra
Created: 11/16/2023
Status: Merged
Merged: 11/16/2023
Merged by: @djc

Base: mainHead: from-ips-clear-capacity


📝 Commits (1)

  • 240a21e Fix initial vec capacity in NameServerConfigGroup::from_ips_clear

📊 Changes

1 file changed (+4 additions, -3 deletions)

View changed files

📝 crates/resolver/src/config.rs (+4 -3)

📄 Description

👋🏻 hi! I happened to spot this minor issue while looking at the source of this function on docs.rs —

Building a NameServerConfigGroup using from_ips_clear currently always causes a reallocation of the underlying Vec<NameServerConfig>, because two config entries are inserted per IP, while capacity is only reserved for one.

This fix adds the missing 2 * constant factor to Vec::with_capacity.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hickory-dns/hickory-dns/pull/2092 **Author:** [@silverlyra](https://github.com/silverlyra) **Created:** 11/16/2023 **Status:** ✅ Merged **Merged:** 11/16/2023 **Merged by:** [@djc](https://github.com/djc) **Base:** `main` ← **Head:** `from-ips-clear-capacity` --- ### 📝 Commits (1) - [`240a21e`](https://github.com/hickory-dns/hickory-dns/commit/240a21eca7141d1fc5dd09ba3f7bb25f601ebdc3) Fix initial vec capacity in NameServerConfigGroup::from_ips_clear ### 📊 Changes **1 file changed** (+4 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/resolver/src/config.rs` (+4 -3) </details> ### 📄 Description 👋🏻 hi! I happened to spot this minor issue while looking at the source of this function on docs.rs — Building a `NameServerConfigGroup` using `from_ips_clear` currently always causes a reallocation of the underlying `Vec<NameServerConfig>`, because two config entries are inserted per IP, while capacity is only reserved for one. This fix adds the missing `2 *` constant factor to `Vec::with_capacity`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 11:09:00 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#2801
No description provided.