Author SHA1 Message Date
Sylvestre Ledru 3dde7c23c5 Add grep benchmarks and CodSpeed CI workflow
Add a divan-based benchmark suite (benches/grep_bench.rs) modeled on the
sed benchmarks, covering literal/fixed-string/regex search, case-insensitive
matching, counting, inversion, line numbers, word/whole-line matching, and
quiet mode. Wire up the dev-dependencies (codspeed-divan-compat, tempfile,
uucore benchmark feature) and a [[bench]] entry.

Add a Benchmarks GitHub Actions workflow running the suite through CodSpeed,
adapted from the sed setup.
2026-05-31 09:43:07 +02:00
9 changed files with 454 additions and 642 deletions
+1 -18
View File
@@ -9,9 +9,6 @@ on:
branches: branches:
- '*' - '*'
permissions:
contents: write # Publish grep instead of discarding
# End the current execution if there is a new changeset in the PR. # End the current execution if there is a new changeset in the PR.
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
@@ -50,21 +47,7 @@ jobs:
shell: bash shell: bash
run: | run: |
cd 'grep' cd 'grep'
cargo build --release --config=profile.release.strip=true cargo build --release
tar -C target/release -cf - grep | zstd -19 -o ../grep-x86_64-unknown-linux-gnu.tar.zst
- name: Publish latest commit
uses: softprops/action-gh-release@v3
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
tag_name: latest-commit
body: |
commit: ${{ github.sha }}
draft: false
prerelease: true
files: |
grep-x86_64-unknown-linux-gnu.tar.zst
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run GNU grep testsuite - name: Run GNU grep testsuite
shell: bash shell: bash
+50
View File
@@ -0,0 +1,50 @@
name: Benchmarks
# spell-checker:ignore codspeed dtolnay Swatinem sccache
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
permissions:
contents: read # to fetch code (actions/checkout)
# End the current execution if there is a new changeset in the PR.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
benchmarks:
name: Run benchmarks (CodSpeed)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.10
- name: Install cargo-codspeed
uses: taiki-e/install-action@v2
with:
tool: cargo-codspeed
- name: Build benchmarks
run: cargo codspeed build -p uu_grep
- name: Run benchmarks
uses: CodSpeedHQ/action@v4
env:
CODSPEED_LOG: debug
with:
mode: simulation
run: cargo codspeed run -p uu_grep > /dev/null
token: ${{ secrets.CODSPEED_TOKEN }}
-37
View File
@@ -1,37 +0,0 @@
name: CodSpeed
on:
push:
branches:
- "main"
pull_request:
# `workflow_dispatch` allows CodSpeed to trigger backtest
# performance analysis in order to generate initial data.
workflow_dispatch:
permissions:
contents: read
id-token: write
jobs:
codspeed:
name: Run benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain, cache and cargo-codspeed binary
uses: moonrepo/setup-rust@v0
with:
channel: stable
cache-target: release
bins: cargo-codspeed
- name: Build the benchmark target(s)
run: cargo codspeed build
- name: Run the benchmarks
uses: CodSpeedHQ/action@v4
with:
mode: simulation
run: cargo codspeed run
-55
View File
@@ -1,55 +0,0 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: ^tests/fixtures/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-added-large-files
- id: check-executables-have-shebangs
- id: check-json
exclude: '\.vscode/(cSpell|extensions)\.json' # cSpell.json and extensions.json use comments
- id: check-shebang-scripts-are-executable
exclude: '.+\.rs' # would be triggered by #![some_attribute]
- id: check-symlinks
- id: check-toml
- id: check-yaml
args: [ --allow-multiple-documents ]
- id: destroyed-symlinks
- id: end-of-file-fixer
- id: mixed-line-ending
args: [ --fix=lf ]
- id: trailing-whitespace
- repo: local
hooks:
- id: rust-linting
name: Rust linting
description: Run cargo fmt on files included in the commit.
entry: cargo +stable fmt --
pass_filenames: true
types: [file, rust]
language: system
- id: rust-clippy
name: Rust clippy
description: Run cargo clippy on files included in the commit.
entry: cargo +stable clippy --workspace --all-targets --all-features -- -D warnings
pass_filenames: false
types: [file, rust]
language: system
- id: cargo-lock-check
name: Cargo.lock sync check
description: Ensure Cargo.lock and fuzz/Cargo.lock are up-to-date.
entry: bash -c 'for dir in . fuzz; do if [ -d "$dir" ]; then ( cd "$dir" && cargo fetch --quiet ); fi; done'
pass_filenames: false
files: 'Cargo\.(toml|lock)$'
language: system
- id: cspell
name: Code spell checker (cspell)
description: Run cspell to check for spelling errors (if available).
entry: bash -c 'if command -v cspell >/dev/null 2>&1; then cspell --no-must-find-files -- "$@"; else echo "cspell not found, skipping spell check"; exit 0; fi' --
pass_filenames: true
language: system
ci:
skip: [rust-linting, rust-clippy, cargo-lock-check, cspell]
Generated
+98 -328
View File
File diff suppressed because it is too large Load Diff
+6 -4
View File
@@ -27,10 +27,12 @@ onig_sys = { version = "*", default-features = false }
uucore = "0.8.0" uucore = "0.8.0"
walkdir = "2.5" walkdir = "2.5"
[dev-dependencies]
divan = { package = "codspeed-divan-compat", version = "4.0.5" }
tempfile = "3.10.1"
uucore = { version = "0.8.0", features = ["benchmark"] }
uutests = "0.8.0"
[[bench]] [[bench]]
name = "grep_bench" name = "grep_bench"
harness = false harness = false
[dev-dependencies]
criterion = { version = "4.7.0", package = "codspeed-criterion-compat" }
uutests = "0.8.0"
-5
View File
@@ -4,7 +4,6 @@
[![dependency status](https://deps.rs/repo/github/uutils/grep/status.svg)](https://deps.rs/repo/github/uutils/grep) [![dependency status](https://deps.rs/repo/github/uutils/grep/status.svg)](https://deps.rs/repo/github/uutils/grep)
[![CodeCov](https://codecov.io/gh/uutils/grep/branch/main/graph/badge.svg)](https://codecov.io/gh/uutils/grep) [![CodeCov](https://codecov.io/gh/uutils/grep/branch/main/graph/badge.svg)](https://codecov.io/gh/uutils/grep)
[![CodSpeed](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/uutils/grep?utm_source=badge)
# Grep, now in Rust # Grep, now in Rust
@@ -30,10 +29,6 @@ cargo build --release
cargo test cargo test
``` ```
## Pre-commit hooks
This project uses [pre-commit](https://pre-commit.com); run `pre-commit install` to enable the git hooks.
## Known Issues ## Known Issues
* Does not take `LANG`, etc., into account for handling file encodings (non-UTF8 matches are treated as binary) * Does not take `LANG`, etc., into account for handling file encodings (non-UTF8 matches are treated as binary)
+243 -116
View File
@@ -1,128 +1,255 @@
// This file is part of the uutils grep package. // Benchmarks for the grep utility
// //
// SPDX-License-Identifier: MIT
//
// This file is part of the uutils grep package.
// It is licensed under the MIT License.
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
use criterion::{Criterion, black_box, criterion_group, criterion_main}; use divan::{Bencher, black_box};
use std::ffi::OsString; use uu_grep::uumain;
use std::path::Path; use uucore::benchmark::{create_test_file, run_util_function};
/// Run grep end-to-end through the real `uumain` entry point. `args` are the /// Build an access-log-like data set with `n` lines.
/// arguments after the program name (flags, pattern, paths). The exit status is ///
/// ignored — we only care about the work performed. /// Roughly a quarter of the lines use a non-default HTTP method / status /
fn run(args: &[&str]) { /// user-agent so that selective patterns match a realistic subset rather than
let mut argv: Vec<OsString> = Vec::with_capacity(args.len() + 1); /// every line or no line at all.
argv.push(OsString::from("grep")); fn access_log(n: usize) -> Vec<u8> {
argv.extend(args.iter().map(OsString::from)); let mut data = Vec::new();
let _ = uu_grep::uumain(argv.into_iter()); for i in 0..n {
} let method = if i % 4 == 0 { "POST" } else { "GET" };
let status = if i % 7 == 0 { 404 } else { 200 };
/// Build a multi-megabyte log-like corpus plus a directory holding it alongside let agent = if i % 3 == 0 {
/// a binary file. Every line contains `worker-<n>` and a `2024-…` timestamp; a "Mozilla/5.0 (X11; Linux x86_64) Chrome/120.0"
/// rare `RAREHIT` marker appears on a handful of lines (≈ every 10000th).
/// Returns `(dir, log_file)`.
fn build_corpus() -> (std::path::PathBuf, std::path::PathBuf) {
let mut content = String::new();
for i in 0..80_000u32 {
if i % 10_000 == 0 {
content.push_str(&format!(
"2024-01-15 10:30:{:02} RAREHIT worker-{i} special marker seen\n",
i % 60
));
} else if i % 100 == 0 {
content.push_str(&format!(
"2024-01-15 10:30:{:02} ERROR worker-{i} connection reset\n",
i % 60
));
} else { } else {
content.push_str(&format!( "curl/8.5.0"
"2024-01-15 10:30:{:02} INFO worker-{i} request handled in {}ms\n", };
i % 60, let line = format!(
i % 1000 "192.168.{}.{} - - [01/Jan/2024:00:00:00 +0000] \"{} /index.html HTTP/1.1\" {} 1234 \"-\" \"{}\"\n",
)); (i / 256) % 256,
} i % 256,
method,
status,
agent,
);
data.extend_from_slice(line.as_bytes());
} }
assert!(content.len() > 4 * 1024 * 1024); data
let dir = std::env::temp_dir().join(format!("uu_grep_bench_{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let log = dir.join("app.log");
std::fs::write(&log, &content).unwrap();
// A binary file (contains NUL) that also holds the marker, so `-I` has
// something to skip while recursing.
let mut binary = vec![0u8, 1, 2, 3];
binary.extend_from_slice(b"RAREHIT in binary blob");
binary.extend(std::iter::repeat_n(0u8, 4096));
std::fs::write(dir.join("data.bin"), &binary).unwrap();
(dir, log)
} }
fn bench_e2e(c: &mut Criterion) { /// Benchmark a literal search that matches nothing.
let (dir, log) = build_corpus(); ///
let file = log.to_str().unwrap(); /// This is the purest measure of raw scan throughput: the whole file is read
let dir_str = dir.to_str().unwrap(); /// and searched but no output is produced.
#[divan::bench]
fn literal_no_match(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let file_path = create_test_file(&access_log(2_000_000), temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
// Pure scanning throughput: `-q` with a pattern that never matches forces a bencher.bench(|| {
// full scan and produces no output. A literal (which a buffer-at-a-time black_box(run_util_function(
// searcher can accelerate) versus an extended-regex control (which cannot). uumain,
{ &["ZZZ_NONEXISTENT_PATTERN_ZZZ", file_path_str],
let mut group = c.benchmark_group("scan"); ));
group.bench_function("literal_no_match", |b| { });
b.iter(|| run(black_box(&["-q", "NONEXISTENT_TOKEN_XYZ", file])))
});
group.bench_function("regex_no_match", |b| {
b.iter(|| run(black_box(&["-q", "-E", "NON[0-9]EXISTENT_TOKEN", file])))
});
group.finish();
}
// Real invocation shapes from the `grep` tldr page, each scanning the whole
// corpus. The `RAREHIT` marker matches only a handful of lines, so output
// stays small while the full-file scan dominates.
{
let mut group = c.benchmark_group("usage");
// Search for a pattern within a file.
group.bench_function("search_pattern", |b| {
b.iter(|| run(black_box(&["RAREHIT", file])))
});
// Search for an exact string (-F).
group.bench_function("fixed_string", |b| {
b.iter(|| run(black_box(&["-F", "RAREHIT", file])))
});
// Recursive search ignoring binary files (-rI).
group.bench_function("recursive_no_binary", |b| {
b.iter(|| run(black_box(&["-rI", "RAREHIT", dir_str])))
});
// Print 3 lines of context (-C 3).
group.bench_function("context", |b| {
b.iter(|| run(black_box(&["-C", "3", "RAREHIT", file])))
});
// Filename + line number with forced color (-Hn --color=always).
group.bench_function("filename_lineno_color", |b| {
b.iter(|| run(black_box(&["-Hn", "--color=always", "RAREHIT", file])))
});
// Print only the matched text (-o).
group.bench_function("only_matching", |b| {
b.iter(|| run(black_box(&["-o", "RAREHIT", file])))
});
// Invert match (-v); `worker-` is on every line, so nothing is printed
// and this measures the full inverted scan.
group.bench_function("invert_match", |b| {
b.iter(|| run(black_box(&["-v", "worker-", file])))
});
// Extended regex, case-insensitive (-Ei).
group.bench_function("extended_icase", |b| {
b.iter(|| run(black_box(&["-Ei", "rarehit", file])))
});
group.finish();
}
let _ = std::fs::remove_dir_all(Path::new(dir_str));
} }
criterion_group!(benches, bench_e2e); /// Benchmark a literal search that matches a subset of lines.
criterion_main!(benches); #[divan::bench]
fn literal_match_some(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let file_path = create_test_file(&access_log(2_000_000), temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
bencher.bench(|| {
black_box(run_util_function(uumain, &["POST", file_path_str]));
});
}
/// Benchmark a literal search that matches every line (counting only).
///
/// `-c` keeps the output bounded so the benchmark measures matching rather than
/// terminal I/O.
#[divan::bench]
fn literal_match_all_count(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let file_path = create_test_file(&access_log(2_000_000), temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
bencher.bench(|| {
black_box(run_util_function(uumain, &["-c", "HTTP", file_path_str]));
});
}
/// Benchmark a fixed-string search (`-F`).
#[divan::bench]
fn fixed_string(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let file_path = create_test_file(&access_log(2_000_000), temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
bencher.bench(|| {
black_box(run_util_function(
uumain,
&["-F", "Chrome/120.0", file_path_str],
));
});
}
/// Benchmark a case-insensitive search (`-i`).
#[divan::bench]
fn case_insensitive(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let file_path = create_test_file(&access_log(2_000_000), temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
bencher.bench(|| {
black_box(run_util_function(uumain, &["-i", "mozilla", file_path_str]));
});
}
/// Benchmark counting matches (`-c`).
#[divan::bench]
fn count(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let file_path = create_test_file(&access_log(2_000_000), temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
bencher.bench(|| {
black_box(run_util_function(uumain, &["-c", "POST", file_path_str]));
});
}
/// Benchmark an inverted match (`-v`).
///
/// Most lines do not contain "POST", so this selects the majority of lines;
/// `-c` bounds the output.
#[divan::bench]
fn invert_match_count(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let file_path = create_test_file(&access_log(2_000_000), temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
bencher.bench(|| {
black_box(run_util_function(uumain, &["-vc", "POST", file_path_str]));
});
}
/// Benchmark printing line numbers (`-n`).
#[divan::bench]
fn line_number(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let file_path = create_test_file(&access_log(1_000_000), temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
bencher.bench(|| {
black_box(run_util_function(uumain, &["-nc", "POST", file_path_str]));
});
}
/// Benchmark word-boundary matching (`-w`).
#[divan::bench]
fn word_match(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let file_path = create_test_file(&access_log(2_000_000), temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
bencher.bench(|| {
black_box(run_util_function(uumain, &["-wc", "GET", file_path_str]));
});
}
/// Benchmark an extended regular expression with alternation (`-E`).
#[divan::bench]
fn extended_regex(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let file_path = create_test_file(&access_log(2_000_000), temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
bencher.bench(|| {
black_box(run_util_function(
uumain,
&["-Ec", "(POST|DELETE|PUT)", file_path_str],
));
});
}
/// Benchmark a basic regular expression with an anchor and character class.
#[divan::bench]
fn basic_regex(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let file_path = create_test_file(&access_log(2_000_000), temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
bencher.bench(|| {
black_box(run_util_function(
uumain,
&["-c", "^192\\.168\\.[0-9]*\\.0 ", file_path_str],
));
});
}
/// Benchmark a Perl-compatible regular expression (`-P`).
#[divan::bench]
fn perl_regex(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let file_path = create_test_file(&access_log(2_000_000), temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
bencher.bench(|| {
black_box(run_util_function(
uumain,
&["-Pc", "\"\\d{3}\" \\d+", file_path_str],
));
});
}
/// Benchmark `--only-matching` (`-o`) extracting a substring from each line.
#[divan::bench]
fn only_matching(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let file_path = create_test_file(&access_log(1_000_000), temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
bencher.bench(|| {
black_box(run_util_function(
uumain,
&["-Eoc", "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+", file_path_str],
));
});
}
/// Benchmark quiet mode (`-q`), which can stop at the first match.
#[divan::bench]
fn quiet_first_match(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let file_path = create_test_file(&access_log(2_000_000), temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
bencher.bench(|| {
black_box(run_util_function(uumain, &["-q", "POST", file_path_str]));
});
}
/// Benchmark searching short numeric lines (many small lines).
#[divan::bench]
fn short_lines(bencher: Bencher) {
let temp_dir = tempfile::tempdir().unwrap();
let mut data = Vec::new();
for i in 0..10_000_000 {
data.extend_from_slice(format!("{i}\n").as_bytes());
}
let file_path = create_test_file(&data, temp_dir.path());
let file_path_str = file_path.to_str().unwrap();
bencher.bench(|| {
black_box(run_util_function(uumain, &["-c", "999", file_path_str]));
});
}
fn main() {
divan::main();
}
+56 -79
View File
@@ -3,12 +3,9 @@
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
#[doc(hidden)] mod context_buffer;
pub mod context_buffer; mod line_buffer;
#[doc(hidden)] mod matcher;
pub mod line_buffer;
#[doc(hidden)]
pub mod matcher;
mod output; mod output;
mod searcher; mod searcher;
@@ -23,8 +20,7 @@ use std::path::Path;
use uucore::error::{FromIo, UResult, USimpleError}; use uucore::error::{FromIo, UResult, USimpleError};
#[derive(Clone, Copy, PartialEq, Eq)] #[derive(Clone, Copy, PartialEq, Eq)]
#[doc(hidden)] enum RegexMode {
pub enum RegexMode {
Fixed, Fixed,
Basic, Basic,
Extended, Extended,
@@ -32,8 +28,7 @@ pub enum RegexMode {
} }
#[derive(Clone, Copy, PartialEq, Eq)] #[derive(Clone, Copy, PartialEq, Eq)]
#[doc(hidden)] enum BinaryMode {
pub enum BinaryMode {
Binary, Binary,
Text, Text,
WithoutMatch, WithoutMatch,
@@ -47,84 +42,79 @@ enum ColorMode {
} }
#[derive(Clone, Copy, PartialEq, Eq)] #[derive(Clone, Copy, PartialEq, Eq)]
#[doc(hidden)] enum DirectoryMode {
pub enum DirectoryMode {
Read, Read,
Skip, Skip,
Recurse, Recurse,
} }
#[derive(Clone, Copy, PartialEq, Eq)] #[derive(Clone, Copy, PartialEq, Eq)]
#[doc(hidden)] enum DeviceMode {
pub enum DeviceMode {
Default, Default,
Read, Read,
Skip, Skip,
} }
#[doc(hidden)] struct ColorConfig<'a> {
pub struct ColorConfig<'a> { matched_selected: &'a str,
pub matched_selected: &'a str, matched_context: &'a str,
pub matched_context: &'a str, filename: &'a str,
pub filename: &'a str, line_number: &'a str,
pub line_number: &'a str, byte_offset: &'a str,
pub byte_offset: &'a str, separator: &'a str,
pub separator: &'a str, selected_line: &'a str,
pub selected_line: &'a str, context_line: &'a str,
pub context_line: &'a str,
pub reverse_video: bool, reverse_video: bool,
pub no_erase: bool, no_erase: bool,
} }
#[doc(hidden)] struct GlobSet {
pub struct GlobSet {
patterns: Vec<glob::Pattern>, patterns: Vec<glob::Pattern>,
} }
#[doc(hidden)] struct Config<'a> {
pub struct Config<'a> {
// Searcher // Searcher
pub directory_mode: DirectoryMode, directory_mode: DirectoryMode,
pub device_mode: DeviceMode, device_mode: DeviceMode,
pub follow_symlinks: bool, follow_symlinks: bool,
pub include_globs: GlobSet, include_globs: GlobSet,
pub exclude_globs: GlobSet, exclude_globs: GlobSet,
pub exclude_dir_globs: GlobSet, exclude_dir_globs: GlobSet,
pub label: &'a str, label: &'a str,
#[cfg(windows)] #[cfg(windows)]
pub strip_cr: bool, strip_cr: bool,
pub binary_mode: BinaryMode, binary_mode: BinaryMode,
pub max_count: Option<u64>, max_count: Option<u64>,
pub before_context: usize, before_context: usize,
pub after_context: usize, after_context: usize,
pub has_context: bool, has_context: bool,
// Matcher // Matcher
pub patterns: &'a [&'a str], patterns: &'a [&'a str],
pub regex_mode: RegexMode, regex_mode: RegexMode,
pub ignore_case: bool, ignore_case: bool,
pub invert_match: bool, invert_match: bool,
pub word_regexp: bool, word_regexp: bool,
pub line_regexp: bool, line_regexp: bool,
// Output // Output
pub quiet: bool, quiet: bool,
pub count: bool, count: bool,
pub show_filename: bool, show_filename: bool,
pub files_with_matches: bool, files_with_matches: bool,
pub files_without_match: bool, files_without_match: bool,
pub only_matching: bool, only_matching: bool,
pub byte_offset: bool, byte_offset: bool,
pub line_number: bool, line_number: bool,
pub initial_tab: bool, initial_tab: bool,
pub null_separator: bool, null_separator: bool,
pub null_data: bool, null_data: bool,
pub line_buffered: bool, line_buffered: bool,
pub no_messages: bool, no_messages: bool,
pub group_separator: Option<&'a str>, group_separator: Option<&'a str>,
pub use_color: bool, use_color: bool,
pub color_config: ColorConfig<'a>, color_config: ColorConfig<'a>,
} }
#[uucore::main(no_signals)] #[uucore::main(no_signals)]
@@ -864,21 +854,8 @@ fn expand_num_shorthand(args: impl Iterator<Item = OsString>) -> Vec<OsString> {
out out
} }
impl Default for GlobSet {
fn default() -> Self {
Self::new()
}
}
impl GlobSet { impl GlobSet {
/// Create an empty GlobSet. fn with_capacity(capacity: usize) -> Self {
pub fn new() -> Self {
Self {
patterns: Vec::new(),
}
}
pub fn with_capacity(capacity: usize) -> Self {
Self { Self {
patterns: Vec::with_capacity(capacity), patterns: Vec::with_capacity(capacity),
} }