mirror of
https://github.com/YosysHQ/yosys
synced 2025-11-05 05:49:15 +00:00
Optimize IdString operations to avoid calling c_str()
This commit is contained in:
parent
2075b3416f
commit
a534fda855
2 changed files with 200 additions and 21 deletions
|
|
@ -373,6 +373,24 @@ namespace RTLIL {
|
|||
EXPECT_EQ(id, id2);
|
||||
}
|
||||
|
||||
TEST_F(KernelRtlilTest, NewIdBeginsWith) {
|
||||
IdString id = NEW_ID;
|
||||
EXPECT_TRUE(id.begins_with("$auto"));
|
||||
EXPECT_FALSE(id.begins_with("xyz"));
|
||||
EXPECT_TRUE(id.begins_with("$auto$"));
|
||||
EXPECT_FALSE(id.begins_with("abcdefghijklmn"));
|
||||
EXPECT_TRUE(id.begins_with("$auto$rtlilTest"));
|
||||
EXPECT_FALSE(id.begins_with("$auto$rtlilX"));
|
||||
}
|
||||
|
||||
TEST_F(KernelRtlilTest, NewIdIndexing) {
|
||||
IdString id = NEW_ID;
|
||||
std::string str = id.str();
|
||||
for (int i = 0; i < GetSize(str) + 1; ++i) {
|
||||
EXPECT_EQ(id[i], str.c_str()[i]);
|
||||
}
|
||||
}
|
||||
|
||||
class WireRtlVsHdlIndexConversionTest :
|
||||
public KernelRtlilTest,
|
||||
public testing::WithParamInterface<std::tuple<bool, int, int>>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue