nickva commented on code in PR #40:
URL: https://github.com/apache/couchdb-config/pull/40#discussion_r945956029


##########
src/config_util.erl:
##########
@@ -72,3 +73,16 @@ fix_path_list(["."|Rest], Acc) ->
     fix_path_list(Rest, Acc);
 fix_path_list([Dir | Rest], Acc) ->
     fix_path_list(Rest, [Dir | Acc]).
+
+% Remove leading and trailing ws from string
+% Implementation used from mochiweb_headers for speed
+% discussion https://github.com/mochi/mochiweb/pull/247
+trim_leading_and_trailing_ws(S) ->
+    trim_and_reverse(trim_and_reverse(S, false), false).
+
+trim_and_reverse([S | Rest], Reversed) when S=:=$ ; S=:=$\n; S=:=$\t ->
+    trim_and_reverse(Rest, Reversed);
+trim_and_reverse(V, false) ->
+    trim_and_reverse(lists:reverse(V), true);
+trim_and_reverse(V, true) ->
+    V.

Review Comment:
   I think so as this doesn't seem to be in the request hot-path and we only 
pay the extra 4 microseconds per line once when we read the file in from disk, 
on the other hand it's one line vs ten or more so maintenance and 
readability-wise it's better to stick with more readable code here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to