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

[r2r] Get rid of fomat, wite macros #1316

Merged
merged 7 commits into from Jun 24, 2022
Merged

[r2r] Get rid of fomat, wite macros #1316

merged 7 commits into from Jun 24, 2022

Conversation

sergeyboyko0791
Copy link

@sergeyboyko0791 sergeyboyko0791 commented Jun 19, 2022

  • Remove unused code from commmon.rs
  • Remove for_c.rs

@sergeyboyko0791 sergeyboyko0791 added this to Todo in MM 2.0 via automation Jun 19, 2022
@sergeyboyko0791 sergeyboyko0791 linked an issue Jun 19, 2022 that may be closed by this pull request
@sergeyboyko0791
Copy link
Author

sergeyboyko0791 commented Jun 20, 2022

I think there is no reason to get rid of log macro at all, until we remove dashboard (see the code below), Gravity and refactor LogState (replacing chunk2log with log::info).
https://github.com/KomodoPlatform/atomicDEX-API/blob/039605956aff256a72dcaa570e83f7c45da74b67/mm2src/coins/lp_coins.rs#L2280-L2285

If we decide to replace our custom logger (as I described above) with the log crate at all, we won't be able to print emotions.

@sergeyboyko0791 sergeyboyko0791 requested review from artemii235 and shamardy and removed request for artemii235 and shamardy June 20, 2022 12:38
@sergeyboyko0791 sergeyboyko0791 moved this from Todo to PR review in MM 2.0 Jun 21, 2022
@sergeyboyko0791 sergeyboyko0791 changed the title [wip] Get rid of fomat, wite macros [r2r] Get rid of fomat, wite macros Jun 21, 2022
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the huge refactoring! I have few questions 🙂

.unwrap();
$crate::log::chunk2log(buf, $crate::log::LogLevel::Info)
let time = $crate::log::short_log_time($crate::now_ms());
let file = ::gstuff::filename (file!());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we maybe also remove gstuff usage here? 🙂

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used in many places. Do you suggest moving it to common crate?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think gstuff::filename is much more efficient than Path::file_name, because it's based on two operations:

  1. Find last / or \ in the string slice
  2. Checks if it's needed to return a slice without .rs suffix

My benchmarks:
gstuff::filename, 1000 iterations: 349.083µs
Path::file_name, 1000 iterations: 1.693791ms

gstuff::filename, 10000 iterations: 4.311166ms
Path::file_name, 10000 iterations: 19.391583ms

How about moving gstuff::filename function to common.rs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about moving gstuff::filename function to common.rs?

Ok :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

mm2src/mm2_main/src/docker_tests.rs Outdated Show resolved Hide resolved
mm2src/mm2_main/src/mm2.rs Show resolved Hide resolved
mm2src/mm2_main/src/mm2.rs Outdated Show resolved Hide resolved
mm2src/mm2_main/src/mm2.rs Outdated Show resolved Hide resolved
* Use `log` macro on `mm2_main`
shamardy
shamardy previously approved these changes Jun 22, 2022
Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work 🔥 !

Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving.

@artemii235 artemii235 merged commit b81acc6 into dev Jun 24, 2022
MM 2.0 automation moved this from PR review to Done Jun 24, 2022
@artemii235 artemii235 deleted the fomat-refactoring branch June 24, 2022 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
MM 2.0
  
Done
Development

Successfully merging this pull request may close these issues.

Remove fomat dependency and log! macro.
3 participants