Skip to content

Commit

Permalink
Merge pull request #205 from froydnj/froydnj-string-identifiers
Browse files Browse the repository at this point in the history
better constructors from `string` for `Identifier` and `Symbol`
  • Loading branch information
jasonroelofs authored Feb 27, 2024
2 parents cb19602 + 41e707f commit 27993c2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions include/rice/rice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3695,7 +3695,7 @@ namespace Rice
Identifier(char const* s);

//! Construct a new Identifier from a string.
Identifier(std::string const string);
Identifier(std::string const& string);

//! Return a string representation of the Identifier.
char const* c_str() const;
Expand Down Expand Up @@ -3729,7 +3729,7 @@ namespace Rice
{
}

inline Identifier::Identifier(std::string const s) : id_(rb_intern(s.c_str()))
inline Identifier::Identifier(std::string const& s) : id_(rb_intern2(s.c_str(), s.size()))
{
}

Expand Down Expand Up @@ -6273,7 +6273,7 @@ namespace Rice
}

inline Symbol::Symbol(std::string const& s)
: Object(detail::protect(rb_id2sym, detail::protect(rb_intern, s.c_str())))
: Object(detail::protect(rb_id2sym, detail::protect(rb_intern2, s.c_str(), s.size())))
{
}

Expand Down
2 changes: 1 addition & 1 deletion rice/Identifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Rice
Identifier(char const* s);

//! Construct a new Identifier from a string.
Identifier(std::string const string);
Identifier(std::string const& string);

//! Return a string representation of the Identifier.
char const* c_str() const;
Expand Down
2 changes: 1 addition & 1 deletion rice/Identifier.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Rice
{
}

inline Identifier::Identifier(std::string const s) : id_(rb_intern(s.c_str()))
inline Identifier::Identifier(std::string const& s) : id_(rb_intern2(s.c_str(), s.size()))
{
}

Expand Down
2 changes: 1 addition & 1 deletion rice/cpp_api/Symbol.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Rice
}

inline Symbol::Symbol(std::string const& s)
: Object(detail::protect(rb_id2sym, detail::protect(rb_intern, s.c_str())))
: Object(detail::protect(rb_id2sym, detail::protect(rb_intern2, s.c_str(), s.size())))
{
}

Expand Down

0 comments on commit 27993c2

Please sign in to comment.