Skip to content

Commit

Permalink
Use special handler to copy immutable string objects
Browse files Browse the repository at this point in the history
  • Loading branch information
markuspf committed Jul 18, 2017
1 parent 2787714 commit cfd0fb0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/stringobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,16 +586,19 @@ Obj TypeString (
**
** 'CleanString' is the function in 'CleanObjFuncs' for strings.
*/
Obj CopyStringImm(Obj list, Int mut)
{
GAP_ASSERT(!IS_MUTABLE_OBJ(list));
return list;
}

Obj CopyString (
Obj list,
Int mut )
{
Obj copy; /* handle of the copy, result */

/* just return immutable objects */
if ( ! IS_MUTABLE_OBJ(list) ) {
return list;
}
GAP_ASSERT(IS_MUTABLE_OBJ(list));

/* make object for copy */
if ( mut ) {
Expand Down Expand Up @@ -2565,7 +2568,7 @@ static Int InitKernel (
/* install the copy method */
for ( t1 = T_STRING; t1 <= T_STRING_SSORT; t1++ ) {
CopyObjFuncs [ t1 ] = CopyString;
CopyObjFuncs [ t1 +IMMUTABLE ] = CopyString;
CopyObjFuncs [ t1 +IMMUTABLE ] = CopyStringImm;
CleanObjFuncs[ t1 ] = CleanString;
CleanObjFuncs[ t1 +IMMUTABLE ] = CleanString;
CopyObjFuncs [ t1 +COPYING ] = CopyStringCopy;
Expand Down

0 comments on commit cfd0fb0

Please sign in to comment.