aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-06-03 11:55:04 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:33 +0200
commite681595f8196c84fa46ca63cd9d67924d6e62325 (patch)
treef3a16ca9b3a4546746509aafabd1f6f0a84025ce
parent6b10fdf08ce0cd183e6c09f6783a3075a7dac632 (diff)
chomp: Don't measure length of string every iteration
-rw-r--r--libcrystfel/src/utils.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libcrystfel/src/utils.c b/libcrystfel/src/utils.c
index 1e225778..411274a1 100644
--- a/libcrystfel/src/utils.c
+++ b/libcrystfel/src/utils.c
@@ -327,10 +327,12 @@ size_t notrail(char *s)
void chomp(char *s)
{
size_t i;
+ size_t len;
if ( s == NULL ) return;
+ len = strlen(s);
- for ( i=0; i<strlen(s); i++ ) {
+ for ( i=0; i<len; i++ ) {
if ( (s[i] == '\n') || (s[i] == '\r') ) {
s[i] = '\0';
return;