Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
fix according to review - use fmtlib
Browse files Browse the repository at this point in the history
  • Loading branch information
wss committed Jan 25, 2019
1 parent bf4ae85 commit 27ca053
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
2 changes: 0 additions & 2 deletions include/dsn/utility/strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,5 @@ char *trim_string(char *s);

// calculate the md5 checksum of buffer
std::string string_md5(const char *buffer, unsigned int length);

std::string to_string_with_precision(const double double_val, const int precision);
}
}
8 changes: 0 additions & 8 deletions src/core/core/strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,5 @@ std::string string_md5(const char *buffer, unsigned length)

return result;
}

std::string to_string_with_precision(const double double_val, const int precision)
{
std::ostringstream out;
out.precision(precision);
out << std::fixed << double_val;
return out.str();
}
}
}
5 changes: 3 additions & 2 deletions src/dist/replication/meta_server/meta_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <sys/stat.h>

#include <boost/lexical_cast.hpp>
#include <fmt/format.h>

#include <dsn/utility/factory_store.h>
#include <dsn/dist/meta_state_service.h>
Expand Down Expand Up @@ -477,9 +478,9 @@ void meta_service::on_query_cluster_info(dsn::message_ex *req)
double primary_stddev, total_stddev;
_state->get_cluster_balance_score(primary_stddev, total_stddev);
response.keys.push_back("primary_replica_count_stddev");
response.values.push_back(utils::to_string_with_precision(primary_stddev, 2));
response.values.push_back(fmt::format("{:.{}f}", primary_stddev, 2));
response.keys.push_back("total_replica_count_stddev");
response.values.push_back(utils::to_string_with_precision(total_stddev, 2));
response.values.push_back(fmt::format("{:.{}f}", total_stddev, 2));
response.err = dsn::ERR_OK;

reply(req, response);
Expand Down

0 comments on commit 27ca053

Please sign in to comment.