According to the passages you quoted, sv_catpvs only accepts a string literal.
const char *str = "foo"; sv_catpvs(sv, "foo");
sv_catpv , on the other hand, accepts any expression that returns a string.
sv_catpv(sv, "foo"); // ok sv_catpv(sv, str); // ok
So why does sv_catpvs exist sv_catpvs all? Because it's faster. The reason sv_catpvs accepts only accepts a string literal - it is a macro that extends
sv_catpvs(sv, "foo")
into something like that
sv_catpvn_flags(sv, "foo", sizeof("foo")-1, SV_GMAGIC)
which permits
sv_catpvn_flags(sv, "foo", 3, SV_GMAGIC)
at compile time. sv_catpv , on the other hand, is forced to use slower strlen .
source share