Skip to content

Add NSUUID.compare(_:) #4769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add NSUUID.compare(_:) #4769

wants to merge 1 commit into from

Conversation

woxtu
Copy link
Contributor

@woxtu woxtu commented Jun 17, 2023

@MaxDesiatov
Copy link
Contributor

@swift-ci test

if buffer[12] != otherUUID.uuid.12 { return buffer[12] < otherUUID.uuid.12 ? .orderedAscending : .orderedDescending }
if buffer[13] != otherUUID.uuid.13 { return buffer[13] < otherUUID.uuid.13 ? .orderedAscending : .orderedDescending }
if buffer[14] != otherUUID.uuid.14 { return buffer[14] < otherUUID.uuid.14 ? .orderedAscending : .orderedDescending }
if buffer[15] != otherUUID.uuid.15 { return buffer[15] < otherUUID.uuid.15 ? .orderedAscending : .orderedDescending }
Copy link
Contributor

Choose a reason for hiding this comment

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

It's frustrating that Swift doesn't have nicer support for fixed-size arrays, but until then I reckon we'll have to live with code such as this 🥲

Copy link
Member

Choose a reason for hiding this comment

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

I'd rather do this by bridging:

_cf_uuid_compare(self.uuid, other.uuid)

@MaxDesiatov MaxDesiatov requested review from jmschonfeld and removed request for parkera August 14, 2023 12:44
if buffer[12] != otherUUID.uuid.12 { return buffer[12] < otherUUID.uuid.12 ? .orderedAscending : .orderedDescending }
if buffer[13] != otherUUID.uuid.13 { return buffer[13] < otherUUID.uuid.13 ? .orderedAscending : .orderedDescending }
if buffer[14] != otherUUID.uuid.14 { return buffer[14] < otherUUID.uuid.14 ? .orderedAscending : .orderedDescending }
if buffer[15] != otherUUID.uuid.15 { return buffer[15] < otherUUID.uuid.15 ? .orderedAscending : .orderedDescending }
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather do this by bridging:

_cf_uuid_compare(self.uuid, other.uuid)

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