]> wimlib.net Git - wimlib/blobdiff - src/lcpit_matchfinder.c
compiler.h: remove _unused_attribute
[wimlib] / src / lcpit_matchfinder.c
index a2d6a1e0cd95200d1f3a5464d8359d5736b14cbe..a1a1c02ae61e9059c7edbc13015991dd727154f1 100644 (file)
@@ -4,21 +4,28 @@
  * A match-finder for Lempel-Ziv compression based on bottom-up construction and
  * traversal of the Longest Common Prefix (LCP) interval tree.
  *
- * The following copying information applies to this specific source code file:
- *
- * Written in 2014-2015 by Eric Biggers <ebiggers3@gmail.com>
- *
- * To the extent possible under law, the author(s) have dedicated all copyright
- * and related and neighboring rights to this software to the public domain
- * worldwide via the Creative Commons Zero 1.0 Universal Public Domain
- * Dedication (the "CC0").
- *
- * This software is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the CC0 for more details.
- *
- * You should have received a copy of the CC0 along with this software; if not
- * see <http://creativecommons.org/publicdomain/zero/1.0/>.
+ * Copyright 2022 Eric Biggers
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -368,8 +375,8 @@ lcpit_advance_one_byte(const u32 cur_pos,
 static void
 expand_SA(void *p, u32 n)
 {
-       typedef u32 _may_alias_attribute aliased_u32_t;
-       typedef u64 _may_alias_attribute aliased_u64_t;
+       typedef u32 __attribute__((may_alias)) aliased_u32_t;
+       typedef u64 __attribute__((may_alias)) aliased_u64_t;
 
        aliased_u32_t *SA = p;
        aliased_u64_t *SA64 = p;
@@ -593,9 +600,7 @@ lcpit_matchfinder_init(struct lcpit_matchfinder *mf, size_t max_bufsize,
        }
 
        mf->min_match_len = min_match_len;
-       mf->nice_match_len = min(nice_match_len,
-                                (max_bufsize <= MAX_NORMAL_BUFSIZE) ?
-                                LCP_MAX : HUGE_LCP_MAX);
+       mf->orig_nice_match_len = nice_match_len;
        return true;
 }
 
@@ -664,6 +669,7 @@ lcpit_matchfinder_load_buffer(struct lcpit_matchfinder *mf, const u8 *T, u32 n)
        build_SA(mf->intervals, T, n, mf->pos_data);
        build_ISA(mf->pos_data, mf->intervals, n);
        if (n <= MAX_NORMAL_BUFSIZE) {
+               mf->nice_match_len = min(mf->orig_nice_match_len, LCP_MAX);
                for (u32 i = 0; i < PREFETCH_SAFETY; i++) {
                        mf->intervals[n + i] = 0;
                        mf->pos_data[n + i] = 0;
@@ -673,6 +679,7 @@ lcpit_matchfinder_load_buffer(struct lcpit_matchfinder *mf, const u8 *T, u32 n)
                build_LCPIT(mf->intervals, mf->pos_data, n);
                mf->huge_mode = false;
        } else {
+               mf->nice_match_len = min(mf->orig_nice_match_len, HUGE_LCP_MAX);
                for (u32 i = 0; i < PREFETCH_SAFETY; i++) {
                        mf->intervals64[n + i] = 0;
                        mf->pos_data[n + i] = 0;