Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Provide a means to control the underlying header storage capacity. #1451

Merged
merged 1 commit into from
Mar 16, 2020

Conversation

ldewailly
Copy link

Motivation:

It's not always possible to initialize HTTPHeaders with all the headers one needs to set. In such case, the underlying array will be expanded as and when needed upon headers being appended. Array provides the means to reserve capacity to optimize such use case. This PR exposes this functionality in HTTPHeaders.

Modifications:

Exposed method reserveCapacity(_ minimumCapacity: Int) and computed variable capacity: Int in HTTPHeaders and added some tests.

Result:

Developers will be able to control the capacity of the underlying headers array as such:

var headers = HTTPHeaders()
headers.reserveCapacity(5)

@swift-server-bot
Copy link

Can one of the admins verify this patch?

8 similar comments
@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

Copy link
Member

@weissi weissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you! lgtm

@weissi
Copy link
Member

weissi commented Mar 16, 2020

@swift-nio-bot add to whitelist

Motivation:

It's not always possible to initialize `HTTPHeaders` with all the headers one needs to set. In such case, the underlying array will be expanded as and when needed upon headers being appended. `Array` provides the means to reserve capacity to optimize such use case. This PR exposes this functionality in `HTTPHeaders`.

Modifications:

Expose method `reserveCapacity(_ minimumCapacity: Int)` and computed variable `capacity: Int` in `HTTPHeaders` and added some tests.

Result:

Developers will be able to control the capacity of the underlying headers array as such:

```
var headers = HTTPHeaders()
headers.reserveCapacity(5)
```
@ldewailly ldewailly force-pushed the http_headers_reserve_capacity branch from 4d8ebf2 to 82ff701 Compare March 16, 2020 17:35
@Lukasa Lukasa added the 🔨 semver/patch No public API change. label Mar 16, 2020
@Lukasa Lukasa added this to the 2.15.0 milestone Mar 16, 2020
@Lukasa Lukasa added 🆕 semver/minor Adds new public API. and removed 🔨 semver/patch No public API change. labels Mar 16, 2020
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. ✨

@Lukasa Lukasa merged commit fefd0c8 into apple:master Mar 16, 2020
pull bot pushed a commit to scope-demo/swift-nio that referenced this pull request Mar 16, 2020
…pple#1451)

Motivation:

It's not always possible to initialize `HTTPHeaders` with all the headers one needs to set. In such case, the underlying array will be expanded as and when needed upon headers being appended. `Array` provides the means to reserve capacity to optimize such use case. This PR exposes this functionality in `HTTPHeaders`.

Modifications:

Expose method `reserveCapacity(_ minimumCapacity: Int)` and computed variable `capacity: Int` in `HTTPHeaders` and added some tests.

Result:

Developers will be able to control the capacity of the underlying headers array as such:

```
var headers = HTTPHeaders()
headers.reserveCapacity(5)
```

Co-authored-by: Ludovic Dewailly <ldewailly@apple.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants