Skip to content

Commit

Permalink
Remove redundant c_str calls
Browse files Browse the repository at this point in the history
Summary: As title.

Reviewed By: NTillmann, ssj933

Differential Revision: D52483602

fbshipit-source-id: f6e763631aa02b78bf69a7ee31dc1e158ad61336
  • Loading branch information
agampe authored and facebook-github-bot committed Jan 3, 2024
1 parent 4533ede commit 8104c40
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions opt/annokill/AnnoKill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ AnnoKill::AnnoKill(

// Load annotations we know and want dead.
for (auto const& anno_name : kill) {
DexType* anno = DexType::get_type(anno_name.c_str());
DexType* anno = DexType::get_type(anno_name);
TRACE(ANNO, 2, "Kill annotation type string %s", anno_name.c_str());
if (anno) {
TRACE(ANNO, 2, "Kill anno: %s", SHOW(anno));
Expand All @@ -94,7 +94,7 @@ AnnoKill::AnnoKill(
// Populate class hierarchy keep map
auto ch = build_type_hierarchy(m_scope);
for (const auto& it : class_hierarchy_keep_annos) {
auto* type = DexType::get_type(it.first.c_str());
auto* type = DexType::get_type(it.first);
auto* type_cls = type ? type_class(type) : nullptr;
if (type_cls == nullptr) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions opt/instrument/Instrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -966,8 +966,8 @@ void InstrumentPass::run_pass(DexStoresVector& stores,
}

// Get the analysis class.
DexType* analysis_class_type = g_redex->get_type(
DexString::get_string(m_options.analysis_class_name.c_str()));
DexType* analysis_class_type =
g_redex->get_type(DexString::get_string(m_options.analysis_class_name));
if (analysis_class_type == nullptr) {
std::cerr << "[InstrumentPass] error: cannot find analysis class: "
<< m_options.analysis_class_name << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion opt/original_name/OriginalNamePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void OriginalNamePass::run_pass(DexStoresVector& stores,
auto simple_name = (lastDot != std::string::npos)
? external_name.substr(lastDot + 1)
: external_name;
auto simple_name_s = DexString::make_string(simple_name.c_str());
auto simple_name_s = DexString::make_string(simple_name);
always_assert_log(
DexField::get_field(cls_type, field_name, string_type) == nullptr,
"field %s already exists!",
Expand Down
2 changes: 1 addition & 1 deletion test/unit/CreatorsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ TEST_F(CreatorsTest, MakeSwitchMultiIndices) {

TEST_F(CreatorsTest, ClassCreator) {
std::string foo("Lfoo;");
ClassCreator cc(DexType::make_type(foo.c_str()));
ClassCreator cc(DexType::make_type(foo));
cc.set_super(type::java_lang_Object());
auto cls = cc.create();
std::string bar("Lbar;");
Expand Down
2 changes: 1 addition & 1 deletion test/unit/EvaluateTypeChecksTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class EvaluateTypeChecksTest : public RedexTest {
public:
void SetUp() override {
auto simple_class = [](const std::string& name, const DexType* super_type) {
ClassCreator cc(DexType::make_type(name.c_str()));
ClassCreator cc(DexType::make_type(name));
cc.set_super(const_cast<DexType*>(super_type));
return cc.create()->get_type();
};
Expand Down
2 changes: 1 addition & 1 deletion test/unit/InitClassLoweringPassTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class InitClassLoweringPassTest : public RedexTest {
add_sfield(c_type, type::_double());

std::string class_name = "LTest;";
ClassCreator creator(DexType::make_type(class_name.c_str()));
ClassCreator creator(DexType::make_type(class_name));
creator.set_super(type::java_lang_Object());
auto signature = class_name + ".foo:()V";
auto method = DexMethod::make_method(signature)->make_concrete(
Expand Down
2 changes: 1 addition & 1 deletion test/unit/MethodSplittingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MethodSplitterTest : public RedexTest {
// Create a totally new class.
size_t c = s_counter.fetch_add(1);
std::string name = std::string("LFoo") + std::to_string(c) + ";";
ClassCreator cc{DexType::make_type(name.c_str())};
ClassCreator cc{DexType::make_type(name)};
cc.set_super(type::java_lang_Object());

auto m =
Expand Down
4 changes: 2 additions & 2 deletions test/unit/ObjectInlinerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ void test_object_inliner(
const std::vector<uint16_t>& srcs,
const std::string& expected_str,
boost::optional<const std::string> callee_ctor_str = boost::none) {
DexType* callee_type = DexType::make_type(callee_class.c_str());
DexType* caller_type = DexType::make_type(caller_class.c_str());
DexType* callee_type = DexType::make_type(callee_class);
DexType* caller_type = DexType::make_type(caller_class);

std::vector<DexFieldRef*> field_refs = {};
for (const auto& field_data : fields) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/PeepholeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PeepholeTest : public RedexTest {
public:
::sparta::s_expr run_peephole_pass(const std::string& code) {
auto class_name = next_class();
ClassCreator creator(DexType::make_type(class_name.c_str()));
ClassCreator creator(DexType::make_type(class_name));
creator.set_super(type::java_lang_Object());
auto signature = class_name + ".foo:()V";
auto method = DexMethod::make_method(signature)->make_concrete(
Expand Down
2 changes: 1 addition & 1 deletion test/unit/SourceBlocksTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SourceBlocksTest : public RedexTest {
// Create a totally new class.
size_t c = s_counter.fetch_add(1);
std::string name = class_name + std::to_string(c) + ";";
ClassCreator cc{DexType::make_type(name.c_str())};
ClassCreator cc{DexType::make_type(name)};
cc.set_super(type::java_lang_Object());

// Empty code isn't really legal. But it does not matter for us.
Expand Down
2 changes: 1 addition & 1 deletion test/unit/SplitHugeSwitchTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SplitHugeSwitchTest : public RedexTest {
// Create a totally new class.
size_t c = s_counter.fetch_add(1);
std::string name = std::string("LFoo") + std::to_string(c) + ";";
ClassCreator cc{DexType::make_type(name.c_str())};
ClassCreator cc{DexType::make_type(name)};
cc.set_super(type::java_lang_Object());

auto m =
Expand Down
2 changes: 1 addition & 1 deletion test/unit/UnreachableLoweringPassTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class UnreachableLoweringPassTest : public RedexTest {
virt_scope::get_vmethods(type::java_lang_Object());

std::string class_name = "LTest;";
ClassCreator creator(DexType::make_type(class_name.c_str()));
ClassCreator creator(DexType::make_type(class_name));
creator.set_super(type::java_lang_Object());
auto signature = class_name + ".foo:()V";
auto method = DexMethod::make_method(signature)->make_concrete(
Expand Down
2 changes: 1 addition & 1 deletion test/unit/object-sensitive-dce/UsedVarsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void optimize(const uv::FixpointIterator& fp_iter, cfg::ControlFlowGraph& cfg) {
// will call resolve_method() during its analysis. resolve_method() needs the
// method to reside in a class hierarchy in order to work correctly.
DexClass* create_simple_class(const std::string& name) {
ClassCreator cc(DexType::make_type(name.c_str()));
ClassCreator cc(DexType::make_type(name));
cc.set_super(type::java_lang_Object());
auto* ctor = DexMethod::make_method(name + ".<init>:()V")
->make_concrete(ACC_PUBLIC, /* is_virtual */ false);
Expand Down

0 comments on commit 8104c40

Please sign in to comment.