improves instruction decoding by avoiding copying, replaces .size()
This commit is contained in:
parent
0d6bf924ed
commit
b1306c3a47
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user