Merge pull request #1809 from wtdcode/perf_improvement
Some performance improvement
This commit is contained in:
commit
89bfdaf2ef
7
MCInst.c
7
MCInst.c
|
@ -17,12 +17,17 @@
|
|||
|
||||
void MCInst_Init(MCInst *inst)
|
||||
{
|
||||
#if 0
|
||||
// this loop consumes 2% of the whole disasm work
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < 48; i++) {
|
||||
inst->Operands[i].Kind = kInvalid;
|
||||
inst->Operands[i].ImmVal = 0;
|
||||
}
|
||||
#endif
|
||||
// unnecessary to initialize in loop . its expensive and inst->size shuold be honored
|
||||
inst->Operands[0].Kind = kInvalid;
|
||||
inst->Operands[0].ImmVal = 0;
|
||||
|
||||
inst->Opcode = 0;
|
||||
inst->OpcodePub = 0;
|
||||
|
|
|
@ -1147,13 +1147,13 @@ static int getID(struct InternalInstruction *insn)
|
|||
}
|
||||
}
|
||||
|
||||
/* The following clauses compensate for limitations of the tables. */
|
||||
if (insn->mode != MODE_64BIT &&
|
||||
insn->vectorExtensionType != TYPE_NO_VEX_XOP) {
|
||||
if (getIDWithAttrMask(&instructionID, insn, attrMask)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* The following clauses compensate for limitations of the tables. */
|
||||
if (insn->mode != MODE_64BIT &&
|
||||
insn->vectorExtensionType != TYPE_NO_VEX_XOP) {
|
||||
/*
|
||||
* The tables can't distinquish between cases where the W-bit is used to
|
||||
* select register size and cases where its a required part of the opcode.
|
||||
|
@ -1218,6 +1218,9 @@ static int getID(struct InternalInstruction *insn)
|
|||
|
||||
return 0;
|
||||
}
|
||||
if (getIDWithAttrMask(&instructionID, insn, attrMask)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((insn->mode == MODE_16BIT || insn->hasOpSize) &&
|
||||
!(attrMask & ATTR_OPSIZE)) {
|
||||
|
|
12
cs.c
12
cs.c
|
@ -554,6 +554,15 @@ static void fill_insn(struct cs_struct *handle, cs_insn *insn, char *buffer, MCI
|
|||
postprinter((csh)handle, insn, buffer, mci);
|
||||
|
||||
#ifndef CAPSTONE_DIET
|
||||
char *tab = strchr (buffer, '\t');
|
||||
if (tab) {
|
||||
*tab = 0;
|
||||
}
|
||||
strncpy (insn->mnemonic, buffer, sizeof (insn->mnemonic) - 1);
|
||||
if (tab) {
|
||||
strcpy (insn->op_str, tab + 1);
|
||||
}
|
||||
#if 0
|
||||
// fill in mnemonic & operands
|
||||
// find first space or tab
|
||||
mnem = insn->mnemonic;
|
||||
|
@ -568,6 +577,7 @@ static void fill_insn(struct cs_struct *handle, cs_insn *insn, char *buffer, MCI
|
|||
}
|
||||
|
||||
*mnem = '\0';
|
||||
#endif
|
||||
|
||||
// we might have customized mnemonic
|
||||
if (handle->mnem_list) {
|
||||
|
@ -588,6 +598,7 @@ static void fill_insn(struct cs_struct *handle, cs_insn *insn, char *buffer, MCI
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
// copy @op_str
|
||||
if (*sp) {
|
||||
// find the next non-space char
|
||||
|
@ -598,6 +609,7 @@ static void fill_insn(struct cs_struct *handle, cs_insn *insn, char *buffer, MCI
|
|||
} else
|
||||
insn->op_str[0] = '\0';
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
// how many bytes will we skip when encountering data (CS_OPT_SKIPDATA)?
|
||||
|
|
Loading…
Reference in New Issue