ehds opened a new pull request, #2288:
URL: https://github.com/apache/brpc/pull/2288
### What problem does this PR solve?
Issue Number:
Problem Summary:
`FlatMap` 中 `Bucket` 的 `Element` 用于存放用户的 key 和 value,用于初始化 element
的空间(`element_space`) 地址要满足 Element 的对齐要求。
> 5.3.4 New [expr.new]
[14] Note: when the allocation function returns a value other than null,
it must be a pointer to a block of storage in which space for the object has
been reserved. The block of storage is assumed to be appropriately aligned and
of the requested size.
一些编译器在开启优化选项后,会根据数据的对齐字节,而选择更高效的指令,例如 `movaps`, 如果实际的数据未按照其对齐要求分配内存,则会导致错误发生。
### What is changed and the side effects?
Changed:
采用 `std::aligned_storage<sizeof(Element), alignof(Element)>` 用于初始化
`element_space`.
Side effects:
- Performance effects(性能影响):
无
- Breaking backward compatibility(向后兼容性):
无
---
### Check List:
- [x] Please make sure your changes are compilable(请确保你的更改可以通过编译).
- [x] When providing us with a new feature, it is best to add related
tests(如果你向我们增加一个新的功能, 请添加相关测试).
- [x] Please follow [Contributor Covenant Code of
Conduct](../../master/CODE_OF_CONDUCT.md).(请遵循贡献者准则).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]