hyperskill / hs-test

A framework that simplifies testing educational projects for Hyperskill. It is built on top of JUnit.
30 stars 10 forks source link

Optimization: Let’s use replace instead of replaceAll #119

Closed rabestro closed 3 years ago

rabestro commented 3 years ago

https://github.com/hyperskill/hs-test/blob/5437461540644124acf234ca875667a8c4e5af7c/src/main/java/org/hyperskill/hstest/common/Utils.java#L43

  1. String::replaceAll uses regular expression engine. In any cases where we need to replace regular string it is better to use String::replace.

  2. .replaceAll("\r\n", "\n").replaceAll("\r", "\n") equals to .replaceAll("\r\n?", "\n")

aaaaaa2493 commented 3 years ago

@rabestro Thanks! Then it's better to just use replace because we have the same line in Python library.

aaaaaa2493 commented 3 years ago

Fixed in https://github.com/hyperskill/hs-test/commit/c31b45447bb6cebfae7607479fd4c5e157fe04d0