Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6128633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:38:56+00:00 2026-05-23T16:38:56+00:00

I have a UUID class that has an inbuilt 16 byte buffer for the

  • 0

I have a UUID class that has an inbuilt 16 byte buffer for the UUID.

The >, <, ==, != overloaded operators just call memcmp() over the 16 byte value.

Since this class is going to be used on a 64-bit architecture only, would it be faster to compare the 128 bits using two 64-bit ints instead?

e.g.
Instead of:

memcmp(uuid1, uuid2, 16) == 0

Can I just do something like:

unsigned long* id1 = (unsigned long*)uuid1;
unsigned long* id2 = (unsigned long*)uuid2;
bool equal = (id1[0] == id2[0] && id1[1] == id2[1]);

Or does the memcmp() function used by G++ do this kind of optimisation already?
On the other hand, not using memcmp() will avoid the function call overhead yes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:38:56+00:00Added an answer on May 23, 2026 at 4:38 pm

    With today’s processors, there’s a very good chance that the comparison is limited by the speed of fetching the bytes from memory. The comparison itself will likely be in parallel with it, whether it’s byte by byte or 64-bit by 64-bit. The only way to be sure is to benchmark it.

    As for the call overhead, it’s quite possible that memcmp is implemented as an intrinsic function with no overhead at all. Check the generated assembly listing to be sure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following POJO: public class SampleBean1 { @Id @GeneratedValue(generator = system-uuid) @GenericGenerator(name
I have a repository class that defines some basic Get/Save/Delete methods. Inside these, I
I have a simple class (for testing purposes) that I am trying to Query
i have the following (partial) hierarchy: @MappedSuperclass public abstract class PersistentEntity { @Id @GeneratedValue(generator=system-uuid)
I have written a util class in Java for webservice call. My util class
I have a Silverlight client that I need to call a web service. The
I have a view that uses one of the class-based generic views (derives from
I have a 2 classes that share a UUID and are uni-directionally mapped. I
Say I have two UUID instances: uuid1 = UUID.randomUUID(); uuid2 = UUID.randomUUID(); If those
I am very interested in postgesql because they have a uuid data type. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.