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

Introduce fmt dependency to simplify string formatting #1139

Merged
merged 7 commits into from
Nov 25, 2022

Conversation

PragmaTwice
Copy link
Member

@PragmaTwice PragmaTwice commented Nov 25, 2022

In this PR, we introduce fmt, the de facto standard of string formatting in C++ and the origin of std::format (c++20) & std::print (c++23), which is also the most popular formatting library in C++, used in softwares like
ceph, mariadb, scylladb and mongodb.

And we can replace the old formatting methods (this PR replaced part of them, far from all):

  • snprintf or similiar C functions: need to specify types like d, f, s, g, and hard to format basic types like uint64_t (need some ugly macros). cannot format custom types. need to create a fixed-length buffer by our own.
  • std::stringstream or similiar stream-like C++ types: very slow, and verbose to write.
  • std::to_string and string concat (like "..." + to_string(num1) + "..." + to_string(num2)): inefficient, and hard to write & read.

fmt is using the MIT license with an exemption clause: https://github.com/fmtlib/fmt/blob/master/LICENSE.rst

torwig
torwig previously approved these changes Nov 25, 2022
Copy link
Contributor

@torwig torwig left a comment

Choose a reason for hiding this comment

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

@PragmaTwice Great Job! It's a really handy and compact way to format strings.

LGTM.

@PragmaTwice PragmaTwice requested a review from torwig November 25, 2022 08:44
@git-hulk
Copy link
Member

@PragmaTwice Changes are good to me, but we need to update the NOTICE as well.

@PragmaTwice
Copy link
Member Author

@PragmaTwice Changes are good to me, but we need to update the NOTICE as well.

Done

@tisonkun
Copy link
Member

Merging...

BTW, NOTICE file can be concise. Depencies' licenses and notices can be simply copied under the licenses folder. Then we don't maintain a big text file (manually) :)

@tisonkun tisonkun merged commit 7b3b6dc into apache:unstable Nov 25, 2022
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.

4 participants