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

refactor logger #295

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

refactor logger #295

wants to merge 1 commit into from

Conversation

neko-para
Copy link
Contributor

@MistEO
Copy link
Member

MistEO commented Dec 10, 2024

这个还整吗

@neko-para
Copy link
Contributor Author

这个还整吗

其实已经能用了来着,只是没测性能变化

@neko-para
Copy link
Contributor Author

这玩意现在的主要问题是,用source_location拿到的file_name并不能在constexpr阶段处理,导致相比于现有实现(基于__FILE__的string_view,可以编译时处理)会额外产生运行开销。现在分支上的实现用一整个location构造了LogStream,导致针对文件名的处理不得不延后到了运行时。要说的话,可以把文件名在外面额外作为一个函数调用结果传进去,大概可以保持现有的效率?或者更进一步,直接先在外面把loc处理好,整一个作为constexpr值塞进去,大概。

老实现
编译时直接确定偏移的位置。

新实现
单独拿出来用的话,编译时也可以确定偏移位置。

@neko-para
Copy link
Contributor Author

理论上如果直接传一整个loc信息的话,可以作为模板参数来搞,唯一的坏处大概就是每一次调用都会产生一个实例(?
不过不清楚几个编译器能不能自动合并函数来着

@neko-para
Copy link
Contributor Author

理论上如果直接传一整个loc信息的话,可以作为模板参数来搞,唯一的坏处大概就是每一次调用都会产生一个实例(? 不过不清楚几个编译器能不能自动合并函数来着

试了下应该是不会合并的,看来还是得用参数传进去

@neko-para
Copy link
Contributor Author

明天找时间重写改改,这PR还是挂太久了

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.

2 participants