Skip to content

Add CharacterSet Benchmarks & Updates to BuiltInUnicodeScalarSet#1751

Open
chloe-yeo wants to merge 3 commits intoswiftlang:mainfrom
chloe-yeo:benchmark/character-set
Open

Add CharacterSet Benchmarks & Updates to BuiltInUnicodeScalarSet#1751
chloe-yeo wants to merge 3 commits intoswiftlang:mainfrom
chloe-yeo:benchmark/character-set

Conversation

@chloe-yeo
Copy link
Contributor

This PR adds benchmarks for CharacterSet and adds cases to BuiltInUnicodeScalarSet to account for types that were previously not accounted for.

Motivation:

This is to lay the groundwork for adding a Swift-native CharacterSet implementation in this repository.

Modifications:

Added benchmarks for CharacterSet and modified the BuiltInUnicodeScalarSet to account for additional built-in sets.

Result:

No behavior changes.

Testing:

Building and unit testing to confirm functions are unused/behavior is the same.

…(#3586)

Co-authored-by: T Liu <iting_liu@apple.com>
@chloe-yeo chloe-yeo requested a review from a team as a code owner February 16, 2026 18:47
@chloe-yeo
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@jmschonfeld jmschonfeld left a comment

Choose a reason for hiding this comment

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

LGTM (knowing that unit tests coming as an eventual followup will cover the new UnicodeScalar Set code and that existing unit tests cover the existing behavior)

Comment on lines +178 to +182
if plane < 3 || plane > 13 {
return true
} else {
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is correct but I believe we also have a followup to improve this to

Suggested change
if plane < 3 || plane > 13 {
return true
} else {
return false
}
return plane < 3 || plane > 13

right?

I think this is less error prone given we've seen bugs caused by copy-paste errors when we manually unroll the boolean checks like this...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep added as follow-up!

case .bitmapEmpty:
// For empty result, return the appropriate fill pattern
if isInverted {
return Data(repeating: 0x00, count: 65536 / 8)
Copy link
Contributor

Choose a reason for hiding this comment

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

I also believe we have a followup task to return a static Data for these ones right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added as follow-up!

@chloe-yeo
Copy link
Contributor Author

@swift-ci please test

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.

3 participants