improves instruction decoding by avoiding copying, replaces .size()

This commit is contained in:
Eyck-Alexander Jentzsch 2024-07-24 08:54:37 +02:00
parent 0d6bf924ed
commit b1306c3a47
1 changed files with 4 additions and 6 deletions

View File

@ -85,15 +85,13 @@ void decoder::populate_decoding_tree(decoding_tree_node& parent) {
}
uint32_t decoder::decode_instr(uint32_t word) { return _decode_instr(this->root, word); }
uint32_t decoder::_decode_instr(decoding_tree_node const& node, uint32_t word) {
if(!node.children.size()) {
if(node.instrs.size() == 1)
return node.instrs[0].index;
for(auto instr : node.instrs) {
if(!node.instrs.empty()) {
for(auto& instr : node.instrs) {
if((instr.mask & word) == instr.value)
return instr.index;
}
} else {
for(auto child : node.children) {
} else if(!node.children.empty()) {
for(auto& child : node.children) {
if(child.value == (node.submask & word)) {
return _decode_instr(child, word);
}