diff options
author | Olly Betts <olly@survex.com> | 2007-09-17 20:10:57 +0000 |
---|---|---|
committer | Olly Betts <olly@survex.com> | 2007-09-17 20:10:57 +0000 |
commit | c836c81acba5ad6815032ccadd13a40bddef607b (patch) | |
tree | 9c0f3c56033900f2e9fe333075fe5d304a4a1e32 /Lib/chicken | |
parent | ef4ca158de95ba31f8255fa1008b1773b2d05258 (diff) | |
download | swig-c836c81acba5ad6815032ccadd13a40bddef607b.tar.gz |
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
Diffstat (limited to 'Lib/chicken')
-rw-r--r-- | Lib/chicken/std_string.i | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Lib/chicken/std_string.i b/Lib/chicken/std_string.i index 36dd82b90..2955d0e2f 100644 --- a/Lib/chicken/std_string.i +++ b/Lib/chicken/std_string.i @@ -35,14 +35,14 @@ namespace std { %typemap(in) string (char* tempptr) { if ($input == C_SCHEME_FALSE) { - $1 = std::string(); + $1.resize(0); } else { if (!C_swig_is_string ($input)) { swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not a string"); - } + } tempptr = SWIG_MakeString($input); - $1 = std::string(tempptr); + $1.assign(tempptr); if (tempptr) SWIG_free(tempptr); } } @@ -51,7 +51,7 @@ namespace std { char* tempptr) { if ($input == C_SCHEME_FALSE) { - temp = std::string(); + temp.resize(0); $1 = &temp; } else { if (!C_swig_is_string ($input)) { @@ -59,7 +59,7 @@ namespace std { "Argument #$argnum is not a string"); } tempptr = SWIG_MakeString($input); - temp = std::string(tempptr); + temp.assign(tempptr); if (tempptr) SWIG_free(tempptr); $1 = &temp; } @@ -79,7 +79,7 @@ namespace std { %typemap(varin) string { if ($input == C_SCHEME_FALSE) { - $1 = std::string(); + $1.resize(0); } else { char *tempptr; if (!C_swig_is_string ($input)) { @@ -87,7 +87,7 @@ namespace std { "Argument #$argnum is not a string"); } tempptr = SWIG_MakeString($input); - $1 = std::string(tempptr); + $1.assign(tempptr); if (tempptr) SWIG_free(tempptr); } } |