hast_compression.c (219354) | hast_compression.c (229778) |
---|---|
1/*- 2 * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sbin/hastd/hast_compression.c 219354 2011-03-06 23:09:33Z pjd $"); | 28__FBSDID("$FreeBSD: head/sbin/hastd/hast_compression.c 229778 2012-01-07 16:09:33Z uqs $"); |
29 30#include <sys/endian.h> 31 32#include <errno.h> 33#include <string.h> 34#include <strings.h> 35 36#include <hast.h> --- 13 unchanged lines hidden (view full) --- 50 PJDLOG_ASSERT((size % sizeof(*p)) == 0); 51 52 /* 53 * This is the fastest method I found for checking if the given 54 * buffer contain all zeros. 55 * Because inside the loop we don't check at every step, we would 56 * get an answer only after walking through entire buffer. 57 * To return early if the buffer doesn't contain all zeros, we probe | 29 30#include <sys/endian.h> 31 32#include <errno.h> 33#include <string.h> 34#include <strings.h> 35 36#include <hast.h> --- 13 unchanged lines hidden (view full) --- 50 PJDLOG_ASSERT((size % sizeof(*p)) == 0); 51 52 /* 53 * This is the fastest method I found for checking if the given 54 * buffer contain all zeros. 55 * Because inside the loop we don't check at every step, we would 56 * get an answer only after walking through entire buffer. 57 * To return early if the buffer doesn't contain all zeros, we probe |
58 * 8 bytes at the begining, in the middle and at the end of the buffer | 58 * 8 bytes at the beginning, in the middle and at the end of the buffer |
59 * first. 60 */ 61 62 size >>= 3; /* divide by 8 */ 63 if ((p[0] | p[size >> 1] | p[size - 1]) != 0) 64 return (false); 65 v = 0; 66 for (i = 0; i < size; i++) --- 217 unchanged lines hidden --- | 59 * first. 60 */ 61 62 size >>= 3; /* divide by 8 */ 63 if ((p[0] | p[size >> 1] | p[size - 1]) != 0) 64 return (false); 65 v = 0; 66 for (i = 0; i < size; i++) --- 217 unchanged lines hidden --- |