#[Burst] Using string.Length in a bursted context

1 messages · Page 1 of 1 (latest)

finite slate
#

I tried to use a hash function that takes a string in a burst context, as shown, but if I use string.Length directly it does not compile. This makes sense.

Then I copied it to a FixedString first, and then it compiles just fine. However, FixedString also uses the string.Length property.

Why does that work without generating an error?

floral trench
#

burst handles this magically

finite slate
#

Okay, so, why does it work for FixedString, but not for me?

floral trench
#

because burst knows what a fixed string is

finite slate
#

a special thing for fixed string is programmed into burst, thus?

is there a way to do the same thing here? or do I just have to live with the copy to the fixed string before accessing the data?

floral trench
#

just make your hash function accept a fixedstring?

#

there is an implicit convert from a string

#

then you don't even have to think about it

finite slate
#

of course, I'm just trying to avoid the copy and make it work for any size string

#

but it doesn't bother me particularly in this case