Skip to content

Commit

Permalink
released 4.0.1
Browse files Browse the repository at this point in the history
fix #277 permit legacy compilation; faster option -l for compressed files; enable an optimization that wasn't enabled
  • Loading branch information
genivia-inc committed Aug 20, 2023
1 parent 4ed7c6d commit ee67800
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 3 deletions.
Binary file modified bin/win32/ugrep.exe
Binary file not shown.
Binary file modified bin/win64/ugrep.exe
Binary file not shown.
36 changes: 35 additions & 1 deletion lib/matcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2566,7 +2566,7 @@ bool Matcher::advance()
}
}
#endif
if (min >= 2 && pat_->npy_ < 16)
if (pat_->npy_ < 16)
{
if (min >= 4)
{
Expand Down Expand Up @@ -2695,6 +2695,40 @@ bool Matcher::advance()
}
}
}
const Pattern::Pred *bit = pat_->bit_;
while (true)
{
const char *s = buf_ + loc;
const char *e = buf_ + end_ - 3;
bool f = true;
while (s < e &&
(f = ((bit[static_cast<uint8_t>(*s)] & 1) &&
(bit[static_cast<uint8_t>(*++s)] & 1) &&
(bit[static_cast<uint8_t>(*++s)] & 1) &&
(bit[static_cast<uint8_t>(*++s)] & 1))))
{
++s;
}
loc = s - buf_;
if (!f)
{
if (s < e && Pattern::predict_match(pma, s))
{
++loc;
continue;
}
set_current(loc);
return true;
}
set_current_match(loc - 1);
(void)peek_more();
loc = cur_ + 1;
if (loc + 3 >= end_)
{
set_current(loc);
return false;
}
}
}
if (min >= 4)
{
Expand Down
6 changes: 6 additions & 0 deletions lib/pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,12 @@ void Pattern::init(const char *options, const uint8_t *pred)
}
}
}
// only one position to pin
if (min_ == 1)
{
nlcs = nlcp;
lcs_ = lcp_;
}
// number of needles required
uint16_t n = nlcp > nlcs ? nlcp : nlcs;
// determine if a needle-based search is worthwhile, below or meeting the thresholds
Expand Down
2 changes: 1 addition & 1 deletion lib/simd_avx512bw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ size_t simd_nlcount_avx512bw(const char*& b, const char *e)
return 0;
size_t n = 0;
// align on 64 bytes
while ((reinterpret_cast<ptrdiff_t>(s) & 0x3f) != 0)
while ((reinterpret_cast<std::ptrdiff_t>(s) & 0x3f) != 0)
n += (*s++ == '\n');
__m512i vlcn = _mm512_set1_epi8('\n');
while (s <= e)
Expand Down
6 changes: 6 additions & 0 deletions src/ugrep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,13 @@ struct Zthread {
{
// write buffer data to the pipe, if the pipe is broken then the receiver is waiting for this thread to join so we drain the rest of the decompressed data
if (is_selected && !drain && write(pipe_fd[1], buf, static_cast<size_t>(len)) < len)
{
// if no next decompression thread and decompressing a single file (not zip), then stop immediately
if (ztchain == NULL && zipinfo == NULL)
break;

drain = true;
}

// decompress the next block of data into the buffer
len = zstream->decompress(buf, maxlen);
Expand Down
2 changes: 1 addition & 1 deletion src/ugrep.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#define UGREP_HPP

// ugrep version
#define UGREP_VERSION "4.0.0"
#define UGREP_VERSION "4.0.1"

// disable mmap because mmap is almost always slower than the file reading speed improvements since 3.0.0
#define WITH_NO_MMAP
Expand Down

0 comments on commit ee67800

Please sign in to comment.