Skip to content

Commit

Permalink
Use rayon
Browse files Browse the repository at this point in the history
To run all regexes at once
  • Loading branch information
Scotsguy committed Dec 30, 2019
1 parent f2e4067 commit dc6421f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 28 deletions.
79 changes: 55 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ reqwest = "0.9.22"
log = { version = "0.4.8", features = ["release_max_level_info"] }
env_logger = "0.7.1"
kankyo = "0.3.0"
rayon = "1.3.0"

[dependencies.serenity]
version = "0.7.3"
Expand Down
7 changes: 3 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use lazy_static::lazy_static;
use log::{debug, error, info};
use rayon::prelude::*;
use regex::Regex;

use reqwest::get;

use serenity::{
Expand All @@ -9,8 +10,6 @@ use serenity::{
utils::Colour,
};

use log::{debug, error, info};

mod parsers;
use parsers::PARSERS;

Expand All @@ -28,7 +27,7 @@ fn main() {
}

fn common_mistakes(input: &str) -> Vec<(&str, String)> {
PARSERS.iter().flat_map(|m| m(input)).collect()
PARSERS.par_iter().flat_map(|m| m(input)).collect()
}

/// Takes a string of an URL, returns the content.
Expand Down

0 comments on commit dc6421f

Please sign in to comment.