') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); btree: cleanup difference, intersection, is_subset by hkBst · Pull Request #147808 · rust-lang/rust · GitHub
Skip to content

btree: cleanup difference, intersection, is_subset - #147808

Merged
bors merged 1 commit into
rust-lang:masterfrom
hkBst:btree-3
Nov 7, 2025
Merged

btree: cleanup difference, intersection, is_subset#147808
bors merged 1 commit into
rust-lang:masterfrom
hkBst:btree-3

Conversation

@hkBst

Copy link
Copy Markdown
Member

No description provided.

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 17, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer

This comment has been minimized.

@rust-cloud-vms
rust-cloud-vmsBotforce-pushed the btree-3 branch 2 times, most recently from 8e45e8f to 87755a7CompareOctober 17, 2025 13:18
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbotrustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Oct 17, 2025
@rust-log-analyzer

This comment has been minimized.

@joboetjoboet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is much cleaner, thank you!

View changes since this review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please omit the changes not related to alloc from this PR – if something breaks here, doing them in a batch makes bisecting really difficult.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

Comment on lines 697 to 706
match self_min.cmp(other_min) {
Less => return false,
Equal => self_iter.next(),
Greater => None,
};
let (other_min, other_max) =
if let (Some(other_min), Some(other_max)) = (other.first(), other.last()) {
(other_min, other_max)
} else {
return false; // other is empty
match self_max.cmp(other_max) {
Greater => return false,
Equal => self_iter.next_back(),
Less => None,
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these values are never used, I find the None arms very confusing, so I wouldn't change this. But a comment on the next calls explaining that they remove self_min/self_max from the iteration wouldn't hurt.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +716 to +717
// skip over elements that are smaller
// happens up to `ITER_PERFORMANCE_TIPPING_SIZE_DIFF * self.len() - 1` times

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find the "happens n times" notes to be particularly helpful – it'd be better to have the comments explain why the action chosen is the right one.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments explain why this ordering is used (from most frequent to least frequent), but I'll see about adding some comments explaining correctness.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added those comments.

Greater => (),
}
}
self.is_empty()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be better to preserve the old control flow, but express it using let-else statements. I.e.:

let(Some(self_min),Some(self_max)) = (self.first(),self.last())else{// This set is empty, and the empty set is a subset of all sets.returntrue;};

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that could work too. I'll give it a try.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty nice actually! Good catch.

@rustbotrustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 1, 2025
@joboetjoboet assigned joboet and unassigned ibraheemdevNov 1, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@hkBst

hkBst commented Nov 4, 2025

Copy link
Copy Markdown
MemberAuthor

@joboet Thanks for your thorough review! I think I addressed all your concerns.

@rustbot ready

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 4, 2025
@hkBst

hkBst commented Nov 4, 2025

Copy link
Copy Markdown
MemberAuthor

@joboet BTW Are there any performance tests for BTree? I could not immediately find them...

@joboet

Copy link
Copy Markdown
Member

@joboet BTW Are there any performance tests for BTree? I could not immediately find them...

There in library/alloctests/benches/btree.

@joboetjoboet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me! I'd be interested in the benchmark results, but don't mind merging this as–is even without them – there aren't really any control-flow changes here.

View changes since this review

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 6, 2025
run-make tests: use edition 2024
Bump run-make tests to edition 2024 to prevent test failures when using 2024 idioms in included code, such as I ran into here: rust-lang#147808.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 6, 2025
run-make tests: use edition 2024
Bump run-make tests to edition 2024 to prevent test failures when using 2024 idioms in included code, such as I ran into here: rust-lang#147808.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 6, 2025
run-make tests: use edition 2024
Bump run-make tests to edition 2024 to prevent test failures when using 2024 idioms in included code, such as I ran into here: rust-lang#147808.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Nov 6, 2025
run-make tests: use edition 2024
Bump run-make tests to edition 2024 to prevent test failures when using 2024 idioms in included code, such as I ran into here: rust-lang#147808.
@hkBst

hkBst commented Nov 6, 2025

Copy link
Copy Markdown
MemberAuthor

From running benchmarks locally I believe there is no perf impact of these changes.

@joboet

Copy link
Copy Markdown
Member

All right! Then
@bors r+

@bors

bors commented Nov 6, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit acd0294 has been approved by joboet

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 6, 2025
rust-timer added a commit that referenced this pull request Nov 6, 2025
Rollup merge of #148528 - hkBst:run-make-tests-1, r=jieyouxu
run-make tests: use edition 2024
Bump run-make tests to edition 2024 to prevent test failures when using 2024 idioms in included code, such as I ran into here: #147808.
@jhprattjhpratt mentioned this pull request Nov 7, 2025
bors added a commit that referenced this pull request Nov 7, 2025
Rollup of 12 pull requests
Successful merges:
- #145768 (Offload device)
- #145992 (Stabilize `vec_deque_pop_if`)
- #147416 (Early return if span is from expansion so we dont get empty span and ice later on)
- #147808 (btree: cleanup difference, intersection, is_subset)
- #148520 (style: Use binary literals instead of hex literals in doctests for `highest_one` and `lowest_one`)
- #148559 (Add typo suggestion for a misspelt Cargo environment variable)
- #148567 (Fix incorrect precedence caused by range expression)
- #148570 (Fix mismatched brackets in generated .dir-locals.el)
- #148575 (fix dev guide link in rustc_query_system/dep_graph/README.md)
- #148578 (core docs: add notes about availability of `Atomic*::from_mut_slice`)
- #148603 (Backport 1.91.1 relnotes to main)
- #148609 (Sync str::rsplit_once example with str::split_once)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 4ad5a39 into rust-lang:masterNov 7, 2025
11 checks passed
@rustbotrustbot added this to the 1.93.0 milestone Nov 7, 2025
rust-timer added a commit that referenced this pull request Nov 7, 2025
Rollup merge of #147808 - hkBst:btree-3, r=joboet
btree: cleanup difference, intersection, is_subset
@hkBst
hkBst deleted the btree-3 branch November 7, 2025 10:22
github-actionsBot pushed a commit to model-checking/verify-rust-std that referenced this pull request Nov 30, 2025
btree: cleanup difference, intersection, is_subset
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-makeArea: port run-make Makefiles to rmake.rsS-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-libsRelevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@hkBst@rustbot@rust-log-analyzer@joboet@bors@ibraheemdev