summaryrefslogtreecommitdiff
path: root/ext/Opcode
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-11-01 15:07:45 +0000
committerNicholas Clark <nick@ccl4.org>2010-11-01 15:07:45 +0000
commite7c4ace073bc59fe5943c4d36e3d72d1954f36b4 (patch)
tree3a9921df064956a585b2508409b588029cc97d1b /ext/Opcode
parentcbc736f3c4431a04bf792982d02220182ea6667f (diff)
downloadperl-e7c4ace073bc59fe5943c4d36e3d72d1954f36b4.tar.gz
Small refactoring of op_names_init() and put_op_bitspec() in Opcode.xs
Change op_names_init() to use memset() rather than a longhand loop, and to call put_op_bitspec() with an explicit length by using STR_WITH_LEN(). As all calls to put_op_bitspec() now pass in a length, remove the code to call strlen() if the passed-in length is zero. This commit brought to you by the campaign for elimination of strlen().
Diffstat (limited to 'ext/Opcode')
-rw-r--r--ext/Opcode/Opcode.xs10
1 files changed, 3 insertions, 7 deletions
diff --git a/ext/Opcode/Opcode.xs b/ext/Opcode/Opcode.xs
index e1af6d5138..7ae6b334f4 100644
--- a/ext/Opcode/Opcode.xs
+++ b/ext/Opcode/Opcode.xs
@@ -55,16 +55,14 @@ op_names_init(pTHX)
hv_store(op_named_bits, op_names[i], strlen(op_names[i]), sv, 0);
}
- put_op_bitspec(aTHX_ ":none",0, sv_2mortal(new_opset(aTHX_ Nullsv)));
+ put_op_bitspec(aTHX_ STR_WITH_LEN(":none"), sv_2mortal(new_opset(aTHX_ Nullsv)));
opset_all = new_opset(aTHX_ Nullsv);
bitmap = SvPV(opset_all, len);
- i = len-1; /* deal with last byte specially, see below */
- while(i-- > 0)
- bitmap[i] = (char)0xFF;
+ memset(bitmap, 0xFF, len-1); /* deal with last byte specially, see below */
/* Take care to set the right number of bits in the last byte */
bitmap[len-1] = (PL_maxo & 0x07) ? ~(0xFF << (PL_maxo & 0x07)) : 0xFF;
- put_op_bitspec(aTHX_ ":all",0, opset_all); /* don't mortalise */
+ put_op_bitspec(aTHX_ STR_WITH_LEN(":all"), opset_all); /* don't mortalise */
}
@@ -80,8 +78,6 @@ put_op_bitspec(pTHX_ const char *optag, STRLEN len, SV *mask)
dMY_CXT;
verify_opset(aTHX_ mask,1);
- if (!len)
- len = strlen(optag);
svp = hv_fetch(op_named_bits, optag, len, 1);
if (SvOK(*svp))
croak("Opcode tag \"%s\" already defined", optag);