[svn:parrot] r45740 - in branches/immutable_strings_part1: include/parrot src/string
bacek at svn.parrot.org
bacek at svn.parrot.org
Sat Apr 17 10:31:23 UTC 2010
Author: bacek
Date: Sat Apr 17 10:31:23 2010
New Revision: 45740
URL: https://trac.parrot.org/parrot/changeset/45740
Log:
Get rid of side-effects in Parrot_str_length
Modified:
branches/immutable_strings_part1/include/parrot/string_funcs.h
branches/immutable_strings_part1/src/string/api.c
Modified: branches/immutable_strings_part1/include/parrot/string_funcs.h
==============================================================================
--- branches/immutable_strings_part1/include/parrot/string_funcs.h Sat Apr 17 10:02:09 2010 (r45739)
+++ branches/immutable_strings_part1/include/parrot/string_funcs.h Sat Apr 17 10:31:23 2010 (r45740)
@@ -231,10 +231,9 @@
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
-INTVAL Parrot_str_length(PARROT_INTERP, ARGMOD(STRING *s))
+INTVAL Parrot_str_length(PARROT_INTERP, ARGIN(const STRING * const s))
__attribute__nonnull__(1)
- __attribute__nonnull__(2)
- FUNC_MODIFIES(*s);
+ __attribute__nonnull__(2);
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
Modified: branches/immutable_strings_part1/src/string/api.c
==============================================================================
--- branches/immutable_strings_part1/src/string/api.c Sat Apr 17 10:02:09 2010 (r45739)
+++ branches/immutable_strings_part1/src/string/api.c Sat Apr 17 10:31:23 2010 (r45740)
@@ -757,7 +757,7 @@
if (encoding == Parrot_fixed_8_encoding_ptr)
s->strlen = len;
else
- (void)Parrot_str_length(interp, s);
+ s->strlen = CHARSET_CODEPOINTS(interp, s);
return s;
}
@@ -770,7 +770,7 @@
if (encoding == Parrot_fixed_8_encoding_ptr)
s->strlen = len;
else
- (void)Parrot_str_length(interp, s);
+ s->strlen = CHARSET_CODEPOINTS(interp, s);
}
else {
s->strlen = s->bufused = 0;
@@ -960,7 +960,7 @@
=over 4
-=item C<INTVAL Parrot_str_length(PARROT_INTERP, STRING *s)>
+=item C<INTVAL Parrot_str_length(PARROT_INTERP, const STRING * const s)>
Calculates and returns the number of characters in the specified Parrot string.
@@ -971,11 +971,10 @@
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
INTVAL
-Parrot_str_length(PARROT_INTERP, ARGMOD(STRING *s))
+Parrot_str_length(PARROT_INTERP, ARGIN(const STRING * const s))
{
ASSERT_ARGS(Parrot_str_length)
- s->strlen = CHARSET_CODEPOINTS(interp, s);
return s->strlen;
}
@@ -1214,7 +1213,7 @@
(char *)src->strstart + end_byte,
src->bufused - end_byte);
- (void)Parrot_str_length(interp, dest);
+ dest->strlen = CHARSET_CODEPOINTS(interp, dest);
return dest;
}
@@ -2603,7 +2602,7 @@
/* Force validating the string */
if (encoding != result->encoding)
- (void)Parrot_str_length(interp, result);
+ result->strlen = CHARSET_CODEPOINTS(interp, result);
if (!CHARSET_VALIDATE(interp, result))
Parrot_ex_throw_from_c_args(interp, NULL,
@@ -3061,8 +3060,8 @@
}
res->bufused = pos - res->strstart;
+ res->strlen = CHARSET_CODEPOINTS(interp, res);
- (void)Parrot_str_length(interp, res);
Parrot_gc_free_fixed_size_storage(interp, ar_len * sizeof (STRING *),
chunks);
More information about the parrot-commits
mailing list