1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vlib: run vfmt over vlib files, so that v doc -m vlib/ can run without warnings

This commit is contained in:
Delyan Angelov
2020-10-21 12:23:03 +03:00
parent 5b1ab3b0bb
commit dab66593fc
27 changed files with 343 additions and 334 deletions

View File

@ -1,14 +1,12 @@
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module cipher
// NOTE: Implement other versions (joe-c)
// xor_bytes xors the bytes in a and b. The destination should have enough
// space, otherwise xor_bytes will panic. Returns the number of bytes xor'd.
pub fn xor_bytes(mut dst []byte, a, b []byte) int {
pub fn xor_bytes(mut dst []byte, a []byte, b []byte) int {
mut n := a.len
if b.len < n {
n = b.len
@ -16,21 +14,19 @@ pub fn xor_bytes(mut dst []byte, a, b []byte) int {
if n == 0 {
return 0
}
safe_xor_bytes(mut dst, a, b, n)
return n
}
// n needs to be smaller or equal than the length of a and b.
pub fn safe_xor_bytes(mut dst []byte, a, b []byte, n int) {
for i in 0..n {
pub fn safe_xor_bytes(mut dst []byte, a []byte, b []byte, n int) {
for i in 0 .. n {
dst[i] = a[i] ^ b[i]
}
}
// fast_xor_words XORs multiples of 4 or 8 bytes (depending on architecture.)
// The slice arguments a and b are assumed to be of equal length.
pub fn xor_words(mut dst []byte, a, b []byte) {
pub fn xor_words(mut dst []byte, a []byte, b []byte) {
safe_xor_bytes(mut dst, a, b, b.len)
}