Skip to content

Commit d69f4e8

Browse files
committed
regex-debug-info => debug-info
1 parent 5d19b84 commit d69f4e8

File tree

7 files changed

+21
-18
lines changed

7 files changed

+21
-18
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ harness = false
9494
default = ["embedded-domain-resolver", "full-regex-handling", "single-thread"]
9595
full-regex-handling = []
9696
single-thread = [] # disables `Send` and `Sync` on `Engine`.
97-
regex-debug-info = []
97+
debug-info = []
9898
css-validation = ["cssparser", "selectors"]
9999
content-blocking = []
100100
embedded-domain-resolver = ["addr"] # Requires setting an external domain resolver if disabled.

src/blocker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,13 +487,13 @@ impl Blocker {
487487
regex_manager.set_discard_policy(new_discard_policy);
488488
}
489489

490-
#[cfg(feature = "regex-debug-info")]
490+
#[cfg(feature = "debug-info")]
491491
pub fn discard_regex(&self, regex_id: u64) {
492492
let mut regex_manager = self.borrow_regex_manager();
493493
regex_manager.discard_regex(regex_id);
494494
}
495495

496-
#[cfg(feature = "regex-debug-info")]
496+
#[cfg(feature = "debug-info")]
497497
pub fn get_regex_debug_info(&self) -> crate::regex_manager::RegexDebugInfo {
498498
let regex_manager = self.borrow_regex_manager();
499499
regex_manager.get_debug_info()

src/engine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ pub struct Engine {
5858
filter_data_context: FilterDataContextRef,
5959
}
6060

61+
#[cfg(feature = "debug-info")]
6162
pub struct EngineDebugInfo {
62-
#[cfg(feature = "regex-debug-info")]
6363
pub regex_debug_info: crate::regex_manager::RegexDebugInfo,
6464

6565
pub flatbuffer_size: usize,
@@ -253,14 +253,14 @@ impl Engine {
253253
self.blocker.set_regex_discard_policy(new_discard_policy);
254254
}
255255

256-
#[cfg(feature = "regex-debug-info")]
256+
#[cfg(feature = "debug-info")]
257257
pub fn discard_regex(&mut self, regex_id: u64) {
258258
self.blocker.discard_regex(regex_id);
259259
}
260260

261+
#[cfg(feature = "debug-info")]
261262
pub fn get_debug_info(&self) -> EngineDebugInfo {
262263
EngineDebugInfo {
263-
#[cfg(feature = "regex-debug-info")]
264264
regex_debug_info: self.blocker.get_regex_debug_info(),
265265
flatbuffer_size: self.filter_data_context.memory.data().len(),
266266
resources_total_length: self.resources.resources_total_length(),

src/regex_manager.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const DEFAULT_DISCARD_UNUSED_TIME: Duration = Duration::from_secs(180);
3939

4040
/// Reports [`RegexManager`] metrics that may be useful for creating an optimized
4141
/// [`RegexManagerDiscardPolicy`].
42-
#[cfg(feature = "regex-debug-info")]
42+
#[cfg(feature = "debug-info")]
4343
pub struct RegexDebugInfo {
4444
/// Information about each regex contained in the [`RegexManager`].
4545
pub regex_data: Vec<RegexDebugEntry>,
@@ -48,7 +48,7 @@ pub struct RegexDebugInfo {
4848
}
4949

5050
/// Describes metrics about a single regex from the [`RegexManager`].
51-
#[cfg(feature = "regex-debug-info")]
51+
#[cfg(feature = "debug-info")]
5252
pub struct RegexDebugEntry {
5353
/// Id for this particular regex, which is constant and unique for its lifetime.
5454
///
@@ -312,7 +312,7 @@ impl RegexManager {
312312
}
313313

314314
/// Discard one regex, identified by its id from a [`RegexDebugEntry`].
315-
#[cfg(feature = "regex-debug-info")]
315+
#[cfg(feature = "debug-info")]
316316
pub fn discard_regex(&mut self, regex_id: u64) {
317317
self.map
318318
.iter_mut()
@@ -322,7 +322,7 @@ impl RegexManager {
322322
});
323323
}
324324

325-
#[cfg(feature = "regex-debug-info")]
325+
#[cfg(feature = "debug-info")]
326326
pub(crate) fn get_debug_regex_data(&self) -> Vec<RegexDebugEntry> {
327327
use itertools::Itertools;
328328
self.map
@@ -336,13 +336,13 @@ impl RegexManager {
336336
.collect_vec()
337337
}
338338

339-
#[cfg(feature = "regex-debug-info")]
339+
#[cfg(feature = "debug-info")]
340340
pub(crate) fn get_compiled_regex_count(&self) -> usize {
341341
self.compiled_regex_count
342342
}
343343

344344
/// Collect metrics that may be useful for creating an optimized [`RegexManagerDiscardPolicy`].
345-
#[cfg(feature = "regex-debug-info")]
345+
#[cfg(feature = "debug-info")]
346346
pub fn get_debug_info(&self) -> RegexDebugInfo {
347347
RegexDebugInfo {
348348
regex_data: self.get_debug_regex_data(),

tests/unit/engine.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,13 @@ mod tests {
218218
let mut engine = Engine::from_rules_parametrised(rules, Default::default(), false, true);
219219
let data = engine.serialize().to_vec();
220220

221-
let debug_info = engine.get_debug_info();
222-
let expected_size = 8_527_344_f32;
223-
assert!(debug_info.flatbuffer_size >= (expected_size * 0.99) as usize);
224-
assert!(debug_info.flatbuffer_size <= (expected_size * 1.01) as usize);
221+
#[cfg(feature = "debug-info")]
222+
{
223+
let debug_info = engine.get_debug_info();
224+
let expected_size = 8_527_344_f32;
225+
assert!(debug_info.flatbuffer_size >= (expected_size * 0.99) as usize);
226+
assert!(debug_info.flatbuffer_size <= (expected_size * 1.01) as usize);
227+
}
225228

226229
let expected_hash: u64 = if cfg!(feature = "css-validation") {
227230
2942520321544562177

tests/unit/filters/network_matchers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ mod match_tests {
678678

679679
#[test]
680680
#[ignore] // Not going to handle lookaround regexes
681-
#[cfg(feature = "regex-debug-info")]
681+
#[cfg(feature = "debug-info")]
682682
fn check_lookaround_regex_handled() {
683683
{
684684
let filter = r#"/^https?:\/\/([0-9a-z\-]+\.)?(9anime|animeland|animenova|animeplus|animetoon|animewow|gamestorrent|goodanime|gogoanime|igg-games|kimcartoon|memecenter|readcomiconline|toonget|toonova|watchcartoononline)\.[a-z]{2,4}\/(?!([Ee]xternal|[Ii]mages|[Ss]cripts|[Uu]ploads|ac|ajax|assets|combined|content|cov|cover|(img\/bg)|(img\/icon)|inc|jwplayer|player|playlist-cat-rss|static|thumbs|wp-content|wp-includes)\/)(.*)/$image,other,script,~third-party,xmlhttprequest,domain=~animeland.hu"#;

tests/unit/regex_manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(all(test, feature = "regex-debug-info"))]
1+
#[cfg(all(test, feature = "debug-info"))]
22
mod tests {
33
use super::super::*;
44

0 commit comments

Comments
 (0)