feat: add NextLabel and Question.Labels - #11
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe PR adds ChangesDomain label iteration
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change adds label iteration and boundary helpers for decoded DNS names, with coverage for escaped, root, and ordinary names. No actionable merge-blocking risk remains after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Labels yields a name's presentation-form labels without allocating, splitting exactly as miekg/dns NextLabel does, so callers that only need labels can drop that dependency. The differential harness checks every decoded name against NextLabel; a benchmark compares the two.
NextLabel is a drop-in for miekg/dns NextLabel on names this package produces, so callers keep their existing loops and drop the import. On the escaping dnswire emits a forward scan that skips escape sequences replaces the backslash-parity backtracking, measuring 17% faster than miekg/dns on typical and escape-heavy names. The differential harness checks every step of every decoded name against miekg/dns.
62925ac to
bcb11f2
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
NextLabel(name string, offset int) (next int, end bool): a drop-in fordns.NextLabelon names this package produces — EDM'ssetQuestionLabelsloop keeps its shape and drops the import. dnswire controls the escaping (dots inside labels are always\.), so a forward scan that skips escape sequences replaces miekg's backslash-parity backtracking. Offset must be a label start.Question.Labels: range-over-func iterator built onNextLabel, yielding labels in presentation form without dots; the root yields nothing.Supersedes #10, which GitHub closed when its stacked base branch was merged and deleted.
Verification
Unit tests:
TestNextLabelwalks empty, root, plain, escaped-dot, escaped-backslash and\DDDnames step by step;TestQuestionLabelscovers the iterator including early break. Coverage stays 100% under-race.Differential harness: every decoded name is split with
dns.NextLabel, and at each label startdnswire.NextLabelmust return the same(next, end)— 200k deterministic messages agree.BenchmarkLabels(ns/op, zero allocs everywhere):dnswire.NextLabelloopdns.NextLabelloopQuestion.Labelswww.example.com.a\.b.\000\255x.example.Summary by CodeRabbit