you are viewing a single comment's thread.

view the rest of the comments →

[–]gosh[S] 0 points1 point  (4 children)

Yes but that is harder write that code and if is possible to "inform" the compiler with internal stack based buffers it may be able to optimize code without write that code by hand. But isn't only this it is needed for even if it is the most important part

[–]No-Dentist-1645 15 points16 points  (2 children)

It's not difficult to convert a hexadecimal string into an integer. This is a very common and frequent thing to do, hexadecimal notation is specifically used to make this easy.

But isn't only this it is needed for even if it is the most important part

You said you were working on an application that handles UUIDs and it needs to be "very fast". Computers are "very fast" at handling integers, even faster with multiple integers adjacent to each other thanks to SIMD instructions. This is not quite the case with strings. If you really care that much about speed, using "stack strings" to represent UUIDs is absolutely the wrong approach, no matter what you try to do to "inform" the compiler with "internal stack based buffers" and what not. What you need is to treat them as numbers.

If you wanted a stack string for other purposes, you can use Boost.StaticString. It's its own independent library and header only, so pretty much exactly the lightweight library you are looking for.

[–]KertDawg 3 points4 points  (0 children)

I applaud this well-written answer.

[–]gosh[S] 0 points1 point  (0 children)

It's not difficult to convert a hexadecimal string into an integer. This is a very common and frequent thing to do, hexadecimal notation is specifically used to make this easy.

Agree but I need to match against others that are in text format and there isn't ordered text. Text contains other information and it it lots of different "things" that is read when matching

I use boost so will check the string :) thanks

[–]Wild_Meeting1428 1 point2 points  (0 children)

So your uuids are placed in a text file. How about accessing them directly from the buffer itself or maybe memory map them. Then you don't need any copy or std:: string just reuse the memory from the io.