diff options
author | Thomas White <taw@physics.org> | 2020-06-03 11:55:04 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:53:33 +0200 |
commit | e681595f8196c84fa46ca63cd9d67924d6e62325 (patch) | |
tree | f3a16ca9b3a4546746509aafabd1f6f0a84025ce | |
parent | 6b10fdf08ce0cd183e6c09f6783a3075a7dac632 (diff) |
chomp: Don't measure length of string every iteration
-rw-r--r-- | libcrystfel/src/utils.c | 4 |
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; |