-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: replace boost lexicast with std algorithms
- Loading branch information
1 parent
63886fb
commit 775f850
Showing
9 changed files
with
18 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
// 2011-11-27 GONG Chen <[email protected]> | ||
// | ||
#include <filesystem> | ||
#include <boost/lexical_cast.hpp> | ||
#include <utf8.h> | ||
#include <rime/resource.h> | ||
#include <rime/service.h> | ||
|
@@ -74,7 +73,7 @@ bool PresetVocabulary::GetWeightForEntry(const string& key, double* weight) { | |
if (!db_ || !db_->Fetch(key, &weight_str)) | ||
return false; | ||
try { | ||
*weight = boost::lexical_cast<double>(weight_str); | ||
*weight = std::stod(weight_str); | ||
} catch (...) { | ||
return false; | ||
} | ||
|
@@ -105,7 +104,7 @@ bool PresetVocabulary::IsQualifiedPhrase(const string& phrase, | |
return false; | ||
} | ||
if (min_phrase_weight_ > 0.0) { | ||
double weight = boost::lexical_cast<double>(weight_str); | ||
double weight = std::stod(weight_str); | ||
if (weight < min_phrase_weight_) | ||
return false; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
// 2013-04-18 GONG Chen <[email protected]> | ||
// | ||
#include <boost/algorithm/string.hpp> | ||
#include <boost/lexical_cast.hpp> | ||
#include <rime/dict/table_db.h> | ||
#include <rime/dict/user_db.h> | ||
|
||
|
@@ -28,7 +27,7 @@ static bool rime_table_entry_parser(const Tsv& row, | |
UserDbValue v; | ||
if (row.size() >= 3 && !row[2].empty()) { | ||
try { | ||
v.commits = boost::lexical_cast<int>(row[2]); | ||
v.commits = std::stoi(row[2]); | ||
const double kS = 1e8; | ||
v.dee = (v.commits + 1) / kS; | ||
} catch (...) { | ||
|
@@ -51,7 +50,7 @@ static bool rime_table_entry_formatter(const string& key, | |
return false; | ||
boost::algorithm::trim(row[0]); // remove trailing space | ||
row[0].swap(row[1]); | ||
row.push_back(boost::lexical_cast<string>(v.commits)); | ||
row.push_back(std::to_string(v.commits)); | ||
return true; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
// 2011-11-23 GONG Chen <[email protected]> | ||
// | ||
#include <algorithm> | ||
#include <boost/lexical_cast.hpp> | ||
#include <rime/common.h> | ||
#include <rime/composition.h> | ||
#include <rime/context.h> | ||
|
@@ -79,7 +78,7 @@ inline static bool is_switch_index(const string& option) { | |
static Switches::SwitchOption switch_by_index(Switches& switches, | ||
const string& option) { | ||
try { | ||
size_t index = boost::lexical_cast<size_t>(option.substr(1)); | ||
size_t index = std::stoul(option.substr(1)); | ||
return switches.ByIndex(index); | ||
} catch (...) { | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
// 2011-12-12 GONG Chen <[email protected]> | ||
// | ||
#include <stdint.h> | ||
#include <boost/lexical_cast.hpp> | ||
#include <rime/common.h> | ||
#include <rime/config.h> | ||
#include <rime/algo/utilities.h> | ||
|
@@ -73,7 +72,7 @@ bool Customizer::UpdateConfigFile() { | |
} | ||
string customization; | ||
if (!custom_path.empty() && fs::exists(custom_path)) { | ||
customization = boost::lexical_cast<string>(Checksum(custom_path.string())); | ||
customization = std::to_string(Checksum(custom_path.string())); | ||
} | ||
if (applied_customization != customization) { | ||
need_update = true; | ||
|