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

Speed-up dbcs.MatchComment. #231

Open
chhsiao1981 opened this issue Jul 1, 2021 · 0 comments
Open

Speed-up dbcs.MatchComment. #231

chhsiao1981 opened this issue Jul 1, 2021 · 0 comments

Comments

@chhsiao1981
Copy link
Collaborator

Provide the github link(s) of the file#line (請提供 github 關於 code 的 link)

https://github.com/Ptt-official-app/go-openbbsmiddleware/blob/main/dbcs/match_comment.go#L56

What would you like to discuss (你想要討論什麼呢?~)

Currently we loop-through all the comment-types and then determine the comment-type with the smallest index.
However, it's highly possible that some comment-types never exist in the whole content, ending-up O(n), where n is number of the bytes in the content.

It's better that we loop-through the content and check whether the byte is the starting point of some comment-type.
Given that we do MatchComment a lot in commentDBCS, this should improve speed significantly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant