-
Notifications
You must be signed in to change notification settings - Fork 32
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
[79_6] Performance tuning on vertex_occurrences in link.cpp #2089
base: branch-1.2
Are you sure you want to change the base?
Conversation
@@ -57,15 +63,22 @@ unregister_pointer (string id, observer which) { | |||
|
|||
void | |||
register_vertex (tree v, soft_link ln) { | |||
list<soft_link>& l= vertex_occurrences (v); | |||
l = list<soft_link> (ln, l); | |||
if (vertex_occurrences->contains (v)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么这里要判断v
是否是vertex_occurrences
的键?如果hashmap不包含对应的键,会原位构造对应的参数,然后返回引用。如果hashset没有默认初始化函数,可以在初始化vertex_occurrences
的时候传个初始对象进去
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用原来的写法,编辑器直接卡死了。所以用了这种朴素的写法。
这块代码看起来没有问题。有经过测试,其他调用这块的代码,可以正常运行吗? |
hashmap<tree, list<soft_link>> vertex_occurrences; | ||
hashmap<string, int> type_count (0); | ||
static int | ||
hash (soft_link l) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数哪里用到了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hashset<soft_link> 需要提供一个 hash函数
通过打开文档测试的,我尝试加一下集成测试 |
What
Use hashset instead list for faster insertion and removal.
How to test your changes?
Use Goldfish.tmu as the test doc: https://github.com/LiiiLabs/goldfish/blob/main/Goldfish.tmu