Skip to content

Commit

Permalink
Add conversion from Symbol to ShortString
Browse files Browse the repository at this point in the history
The built in Julia method to convert from Symbols to Strings is nonallocating and is a no-op that just reuses the pointer to the interned string, so the conversion is the same as from string.
  • Loading branch information
saolof authored Mar 30, 2021
1 parent f55c3ae commit ab85c69
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ end

ShortString{T}(s::ShortString{T}) where {T} = s

ShortString(s::Symbol) where {T} = ShortString{T}(String(s))

function ShortString{T}(s::ShortString{S}) where {T, S}
sz = sizeof(s)
check_size(T, sz)
Expand Down

0 comments on commit ab85c69

Please sign in to comment.