Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

buffer.cpp的makeSpace_优化 #115

Open
Yuan-GG opened this issue Nov 13, 2024 · 0 comments
Open

buffer.cpp的makeSpace_优化 #115

Yuan-GG opened this issue Nov 13, 2024 · 0 comments

Comments

@Yuan-GG
Copy link

Yuan-GG commented Nov 13, 2024

原本的makeSpace_是根据前置字节+可读字节与len判断,容不下len时resize(writePos_ + len + 1)。想极端一点:这个如果当len刚好是prependableBytes()+1,而且之后的读都没比这个大的话,那不是一直占用没用到的字节?因为writableBytes()已经是0了,所以就得扩充额外的前置字节+1,但是理论上扩充长度为1,然后再把可读前移,就能放下了,感觉没必要扩充额外字节。
所以就修改了扩充字节数以及把else分支取消,无论怎么样都需要前移
image

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

No branches or pull requests

1 participant