-
Notifications
You must be signed in to change notification settings - Fork 401
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
WIP: clang-tidy fixes around const std::string references. #1764
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,33 +29,33 @@ | |
#include "vtr_memory.h" | ||
|
||
void Hashtable::destroy_free_items() { | ||
for (auto kv : my_map) | ||
for (const auto& kv : my_map) | ||
vtr::free(kv.second); | ||
} | ||
|
||
void Hashtable::add(std::string key, void* item) { | ||
this->my_map.emplace(key, item); | ||
void Hashtable::add(const std::string& key, void* item) { | ||
this->my_map.insert({key, item}); | ||
} | ||
|
||
void* Hashtable::remove(std::string key) { | ||
void* Hashtable::remove(const std::string& key) { | ||
void* value = NULL; | ||
auto v = this->my_map.find(key); | ||
if (v != this->my_map.end()) { | ||
value = v->second; | ||
this->my_map.erase(v); | ||
value = this->my_map[key]; | ||
this->my_map.erase(key); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, this also doesn't look like the right strategy. Here again we force the map to look up the value from the key. |
||
} | ||
return value; | ||
} | ||
|
||
void* Hashtable::get(std::string key) { | ||
void* Hashtable::get(const std::string& key) { | ||
void* value = NULL; | ||
auto v = this->my_map.find(key); | ||
if (v != this->my_map.end()) | ||
value = v->second; | ||
value = this->my_map[key]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, this should be the original |
||
|
||
return value; | ||
} | ||
|
||
bool Hashtable::is_empty() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might want to make this |
||
return my_map.empty(); | ||
return (my_map.size() == 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This as well should be the original code |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
#include <stdarg.h> | ||
#include <math.h> | ||
#include <algorithm> | ||
#include <utility> | ||
#include "odin_globals.h" | ||
#include "odin_types.h" | ||
|
||
|
@@ -520,7 +521,7 @@ void change_to_number_node(ast_node_t* node, VNumber number) { | |
|
||
node->type = NUMBERS; | ||
node->types.identifier = temp_ident; | ||
node->types.vnumber = new VNumber(number); | ||
node->types.vnumber = new VNumber(std::move(number)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd probably keep changes that involve std::move in a separate change to keep it by (I'd only use std::move if really needed. It more uglifies code otherwise) |
||
} | ||
|
||
/*--------------------------------------------------------------------------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ struct Abc_ManTime_t_ | |
|
||
#define TOLERANCE 0.001 | ||
|
||
static inline int Abc_FloatEqual( float x, float y ) { return fabs(x-y) < TOLERANCE; } | ||
static inline int Abc_FloatEqual( float x, float y ) { return fabsf(x-y) < TOLERANCE; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The abc/ directory is probably also something that is just imported and we shouldn't touch too much. |
||
|
||
// static functions | ||
static Abc_ManTime_t * Abc_ManTimeStart( Abc_Ntk_t * pNtk ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a good strategy, the original
v = v->second
is what we want.Because otherwise what we do here is to look up the value again which we already did before.