- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
根据 perlapi , sv_catpv()
工作原理如下:
Concatenates the
NUL
-terminated string onto the end of the string which is in the SV. If the SV has the UTF-8 status set, then the bytes appended should be valid UTF-8. Handles 'get' magic, but not 'set' magic.
void sv_catpv(SV *const sv, const char* ptr)
sv_catpvs()
,虽然,这样做:
Like
sv_catpvn
, but takes a literal string instead of a string/length pair.
void sv_catpvs(SV* sv, const char* s)
sv_catpvn()
:
Concatenates the string onto the end of the string which is in the SV. The
len
indicates number of bytes to copy. If the SV has the UTF-8 status set, then the bytes appended should be valid UTF-8. Handles 'get' magic, but not 'set' magic.
void sv_catpvn(SV *dsv, const char *sstr, STRLEN len)
sv_catpvn
与
sv_catpv
做同样的事情除了它将字符串长度作为单独的参数,和
sv_catpvs
与
sv_catpvn
相同除了它需要文字字符串。
sv_catpv
之间有什么细微的差别吗?和
sv_catpvs
我失踪了,还是他们只是做同一件事的两种方法?
最佳答案
根据您引用的段落,sv_catpvs
只需要一个字符串文字。
const char *str = "foo";
sv_catpvs(sv, "foo"); // ok
sv_catpvs(sv, str); // ERROR
sv_catpv
,另一方面,接受任何返回字符串的表达式。
sv_catpv(sv, "foo"); // ok
sv_catpv(sv, str); // ok
sv_catpvs
存在吗?因为它更快。原因
sv_catpvs
只需要一个字符串文字是它是一个扩展的宏
sv_catpvs(sv, "foo")
sv_catpvn_flags(sv, "foo", sizeof("foo")-1, SV_GMAGIC)
sv_catpvn_flags(sv, "foo", 3, SV_GMAGIC)
sv_catpv
,另一方面,被迫使用较慢的
strlen
.
关于perl - sv_catpv() 和 sv_catpvs() 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26637496/
根据 perlapi , sv_catpv()工作原理如下: Concatenates the NUL-terminated string onto the end of the string whi
我是一名优秀的程序员,十分优秀!