Skip to content

Conversation

@guoye-zhang
Copy link
Contributor

@guoye-zhang guoye-zhang requested a review from ekinnear October 23, 2024 19:29
#endif
self.lock.deallocate()
}
let lock = LockStorage.create(value: ())
Copy link
Member

Choose a reason for hiding this comment

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

LockStorage is a class so it already gives us reference semantics. We should be able to drop the _Storage class here now and make it a struct. Then put that struct into the LockStorage that should save us an allocation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we do that, both fields and index need to be a part of LockStorage. lock currently only protects index in the situation where there are multiple HTTPFields sharing the same storage. Can I add an unsafe accessor from LockStorage for fields access?

Copy link
Member

Choose a reason for hiding this comment

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

I see. I didn't know we just protected one. I think it's fine if we leave it as is in the PR. We can revisit later if we find that allocation problematic.

@guoye-zhang guoye-zhang merged commit 70cda1b into apple:main Oct 24, 2024
16 of 26 checks passed
@guoye-zhang guoye-zhang deleted the lock branch October 24, 2024 20:19
@guoye-zhang guoye-zhang mentioned this pull request Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants