diff options
author | Karl Williamson <khw@cpan.org> | 2017-10-31 08:30:38 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2017-11-06 12:50:05 -0700 |
commit | b59bf0b2884b21b6f3ce5eca607ab7a6096d87f5 (patch) | |
tree | 8f7f056070732c24842887baa1d18b6a54a9f7d1 /vms | |
parent | c8b388b0c776dab4a28db03739aff4d64daccada (diff) | |
download | perl-b59bf0b2884b21b6f3ce5eca607ab7a6096d87f5.tar.gz |
Use memEQs, memNEs in core files
Where the length is known, we can use these functions which relieve
the programmer and the program reader from having to count characters.
The memFOO functions should also be slightly faster than the strFOO
equivalents.
In some instances in this commit, hard coded numbers are used. These
come from the 'case' statement values that apply to them.
Diffstat (limited to 'vms')
-rw-r--r-- | vms/vms.c | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -1078,7 +1078,7 @@ Perl_my_getenv(pTHX_ const char *lnm, bool sys) } for (cp1 = lnm, cp2 = eqv; *cp1; cp1++,cp2++) *cp2 = toUPPER_A(*cp1); - if (cp1 - lnm == 7 && !strncmp(eqv,"DEFAULT",7)) { + if (memEQs(eqv, cp1 - lnm, "DEFAULT")) { int len; getcwd(eqv,LNM$C_NAMLENGTH); @@ -1174,7 +1174,7 @@ Perl_my_getenv_len(pTHX_ const char *lnm, unsigned long *len, bool sys) } for (cp1 = lnm, cp2 = buf; *cp1; cp1++,cp2++) *cp2 = toUPPER_A(*cp1); - if (cp1 - lnm == 7 && !strncmp(buf,"DEFAULT",7)) { + if (memEQs(buf, cp1 - lnm, "DEFAULT")) { char * zeros; getcwd(buf,LNM$C_NAMLENGTH); @@ -7246,7 +7246,7 @@ int_tounixspec(const char *spec, char *rslt, int * utf8_fl) if (*(cp2+1) == ']' || *(cp2+1) == '>') { while (*(cp2+1) == ']' || *(cp2+1) == '>' || *(cp2+1) == '[' || *(cp2+1) == '<') cp2++; - if (!strncmp(cp2,"[000000",7) && (*(cp2+7) == ']' || + if (memEQs(cp2,"[000000") && (*(cp2+7) == ']' || *(cp2+7) == '>' || *(cp2+7) == '.')) cp2 += 7; } else if ( *(cp2+1) == '.' && *(cp2+2) == '.') { @@ -7990,13 +7990,9 @@ posix_to_vmsspec_hardway(char *vmspath, int vmspath_len, const char *unixpath, nextslash = strchr(&unixptr[1],'/'); seg_len = 0; if (nextslash != NULL) { - int cmp; seg_len = nextslash - &unixptr[1]; my_strlcpy(vmspath, unixptr, seg_len + 2); - cmp = 1; - if (seg_len == 3) { - cmp = strncmp(vmspath, "dev", 4); - if (cmp == 0) { + if (memEQs(vmspath, seg_len, "dev")) { sts = slash_dev_special_to_vms(unixptr, vmspath, vmspath_len); if (sts == SS$_NORMAL) return SS$_NORMAL; |