Skip to content

Commit 1ad7381

Browse files
committed
kernel: some stringobj tweaks
* make MakeImmutableString static line * remove unused `IsStringConvFilt` * rewrite MakeString to not use C_NEW_STRING
1 parent 2c7d01f commit 1ad7381

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

src/stringobj.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,8 +1368,6 @@ void ConvString (
13681368
** otherwise. If <obj> is a string it changes its representation to the
13691369
** string representation.
13701370
*/
1371-
Obj IsStringConvFilt;
1372-
13731371
Int IsStringConv (
13741372
Obj obj )
13751373
{
@@ -1388,17 +1386,6 @@ Int IsStringConv (
13881386
}
13891387

13901388

1391-
/****************************************************************************
1392-
**
1393-
*F MakeImmutableString( <str> ) make a string immutable in place
1394-
**
1395-
*/
1396-
1397-
void MakeImmutableString( Obj str )
1398-
{
1399-
RetypeBag(str, IMMUTABLE_TNUM(TNUM_OBJ(str)));
1400-
}
1401-
14021389
Obj ConvImmString(Obj str)
14031390
{
14041391
Obj result;

src/stringobj.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,15 @@ extern Int IsStringConv (
321321
memcpy( CHARS_STRING(string), (cstr), tmp_len ); \
322322
} while ( 0 );
323323

324+
324325
/****************************************************************************
325326
**
326-
*F MakeImmutableString( <str> ) make a string immutable in place
327-
**
327+
*F MakeImmutableString( <str> ) . . . . . . make a string immutable in place
328328
*/
329-
330-
void MakeImmutableString(Obj str);
329+
static inline void MakeImmutableString(Obj str)
330+
{
331+
RetypeBag(str, IMMUTABLE_TNUM(TNUM_OBJ(str)));
332+
}
331333

332334

333335
// Functions to create mutable and immutable GAP strings from C strings.
@@ -336,15 +338,16 @@ void MakeImmutableString(Obj str);
336338

337339
static inline Obj MakeString(const Char * cstr)
338340
{
339-
Obj result;
340-
C_NEW_STRING(result, strlen(cstr), cstr);
341+
size_t len = strlen(cstr);
342+
Obj result = NEW_STRING(len);
343+
memcpy(CHARS_STRING(result), cstr, len);
341344
return result;
342345
}
343346

344347
static inline Obj MakeImmString(const Char * cstr)
345348
{
346349
Obj result = MakeString(cstr);
347-
RetypeBag(result, IMMUTABLE_TNUM(T_STRING));
350+
MakeImmutableString(result);
348351
return result;
349352
}
350353

0 commit comments

Comments
 (0)