summaryrefslogtreecommitdiff
path: root/src/fileio.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-06-01 23:37:39 +0200
committerBram Moolenaar <Bram@vim.org>2010-06-01 23:37:39 +0200
commit04c9bafa7136564e3059d493dffa84a4c9b6dfb7 (patch)
tree6f000d5eca2d4494d97cb638308c7c95d471f3de /src/fileio.c
parent8cd213c09a3598834888d81deb45ff17e6654a86 (diff)
downloadvim-git-04c9bafa7136564e3059d493dffa84a4c9b6dfb7.tar.gz
Made crypt/decrypt faster.
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 4a9a7f10e..889e4ff44 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1426,8 +1426,7 @@ retry:
* Decrypt the read bytes.
*/
if (cryptkey != NULL && size > 0)
- for (p = ptr; p < ptr + size; ++p)
- ZDECODE(*p);
+ crypt_decode(ptr, size);
#endif
}
skip_read = FALSE;
@@ -3004,7 +3003,6 @@ fwrite_crypt(buf, ptr, len, fp)
{
char_u *copy;
char_u small_buf[100];
- int ztemp, t;
size_t i;
if (*buf->b_p_key == NUL)
@@ -3017,11 +3015,7 @@ fwrite_crypt(buf, ptr, len, fp)
if (copy == NULL)
return 0;
}
- for (i = 0; i < len; ++i)
- {
- ztemp = ptr[i];
- copy[i] = ZENCODE(ztemp, t);
- }
+ crypt_encode(ptr, len, copy);
i = fwrite(copy, len, (size_t)1, fp);
if (copy != small_buf)
vim_free(copy);
@@ -3039,12 +3033,10 @@ read_string_decrypt(buf, fd, len)
int len;
{
char_u *ptr;
- char_u *p;
ptr = read_string(fd, len);
if (ptr != NULL || *buf->b_p_key != NUL)
- for (p = ptr; p < ptr + len; ++p)
- ZDECODE(*p);
+ crypt_decode(ptr, len);
return ptr;
}
@@ -5678,15 +5670,7 @@ buf_write_bytes(ip)
#ifdef FEAT_CRYPT
if (flags & FIO_ENCRYPTED) /* encrypt the data */
- {
- int ztemp, t, i;
-
- for (i = 0; i < len; i++)
- {
- ztemp = buf[i];
- buf[i] = ZENCODE(ztemp, t);
- }
- }
+ crypt_encode(buf, len, buf);
#endif
/* Repeat the write(), it may be interrupted by a signal. */