When wrapping C++ code, generate code which uses
std::string::assign(PTR, LEN) rather than assigning std::string(PTR, LEN). Using assign generates more efficient code (tested with GCC 4.1.2). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9936 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ef4ca158de
commit
c836c81acb
11 changed files with 46 additions and 45 deletions
|
|
@ -25,13 +25,13 @@ namespace std {
|
|||
%typemap(in, pikedesc="tStr") string {
|
||||
if ($input.type != T_STRING)
|
||||
Pike_error("Bad argument: Expected a string.\n");
|
||||
$1 = std::string(STR0($input.u.string));
|
||||
$1.assign(STR0($input.u.string));
|
||||
}
|
||||
|
||||
%typemap(in, pikedesc="tStr") const string & (std::string temp) {
|
||||
if ($input.type != T_STRING)
|
||||
Pike_error("Bad argument: Expected a string.\n");
|
||||
temp = std::string(STR0($input.u.string));
|
||||
temp.assign(STR0($input.u.string));
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
|
|
@ -45,14 +45,14 @@ namespace std {
|
|||
|
||||
%typemap(directorout) string {
|
||||
if ($input.type == T_STRING)
|
||||
$result = std::string(STR0($input.u.string));
|
||||
$result.assign(STR0($input.u.string));
|
||||
else
|
||||
throw Swig::DirectorTypeMismatchException("string expected");
|
||||
}
|
||||
|
||||
%typemap(directorout) const string & (std::string temp) {
|
||||
if ($input.type == T_STRING) {
|
||||
temp = std::string(STR0($input.u.string));
|
||||
temp.assign(STR0($input.u.string));
|
||||
$result = &temp;
|
||||
} else {
|
||||
throw Swig::DirectorTypeMismatchException("string expected");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue