Skip to content

refactor: Add empty() method to TagSet and use it for emptiness checks#377

Open
yurekami wants to merge 1 commit into
deepseek-ai:mainfrom
yurekami:refactor/tagset-empty-method
Open

refactor: Add empty() method to TagSet and use it for emptiness checks#377
yurekami wants to merge 1 commit into
deepseek-ai:mainfrom
yurekami:refactor/tagset-empty-method

Conversation

@yurekami
Copy link
Copy Markdown
Contributor

@yurekami yurekami commented Jan 4, 2026

Summary

  • Adds empty() method to TagSet class for consistent container interface
  • Replaces .size() > 0 checks with !.empty() in ScopedMetricsWriter

Motivation

This follows the clang-tidy readability-container-size-empty guideline which recommends using empty() instead of comparing size() to zero.

Benefits:

  • Readability: !.empty() is more idiomatic and clearer than .size() > 0
  • Consistency: Aligns TagSet with standard container interfaces
  • Future-proofing: empty() can be more efficient than size() == 0 for some container types

Changes

  1. src/common/monitor/Sample.h: Added bool empty() const method to TagSet class
  2. src/common/monitor/ScopedMetricsWriter.h: Replaced 3 instances of .size() > 0 with !.empty()

Test plan

  • Existing tests should pass (no behavioral change)
  • Code review for correctness

🤖 Generated with Claude Code

Add empty() method to TagSet class for consistent container interface
and replace .size() > 0 checks with !.empty() in ScopedMetricsWriter.

This follows the clang-tidy readability-container-size-empty guideline
which recommends using empty() instead of comparing size() to zero.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant