diff options
author | Adriaan Moors <adriaanm@gmail.com> | 2012-10-19 16:41:52 -0700 |
---|---|---|
committer | Adriaan Moors <adriaanm@gmail.com> | 2012-10-19 16:41:52 -0700 |
commit | caa1b7b4b0ae7af2eb4cafe0ef27d06be17cbcf5 (patch) | |
tree | 90c4c7de1fdfd140ee18a6d0ff38b96c9fa67aa7 /src | |
parent | d6ee8a1bb28ab2ac5f8c8772cda748620db924d9 (diff) | |
parent | aa273966e9d6085cafcf31615755c13ba8dfab44 (diff) | |
download | scala-caa1b7b4b0ae7af2eb4cafe0ef27d06be17cbcf5.tar.gz scala-caa1b7b4b0ae7af2eb4cafe0ef27d06be17cbcf5.tar.bz2 scala-caa1b7b4b0ae7af2eb4cafe0ef27d06be17cbcf5.zip |
Merge pull request #1501 from vigdorchik/doc_strings
Remove unneeded calls to substring()
Diffstat (limited to 'src')
-rwxr-xr-x | src/compiler/scala/tools/nsc/util/DocStrings.scala | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/util/DocStrings.scala b/src/compiler/scala/tools/nsc/util/DocStrings.scala index b096e1bc03..6113b54403 100755 --- a/src/compiler/scala/tools/nsc/util/DocStrings.scala +++ b/src/compiler/scala/tools/nsc/util/DocStrings.scala @@ -100,10 +100,10 @@ object DocStrings { * can override the parent symbol's sections */ def mergeUsecaseSections(str: String, idxs: List[Int]): List[Int] = { - idxs.indexWhere(str.substring(_).startsWith("@usecase")) match { + idxs.indexWhere(str.startsWith("@usecase", _)) match { case firstUCIndex if firstUCIndex != -1 => val commentSections = idxs.take(firstUCIndex) - val usecaseSections = idxs.drop(firstUCIndex).filter(str.substring(_).startsWith("@usecase")) + val usecaseSections = idxs.drop(firstUCIndex).filter(str.startsWith("@usecase", _)) commentSections ::: usecaseSections case _ => idxs @@ -114,7 +114,7 @@ object DocStrings { * Merge the inheritdoc sections, as they never make sense on their own */ def mergeInheritdocSections(str: String, idxs: List[Int]): List[Int] = - idxs.filterNot(str.substring(_).startsWith("@inheritdoc")) + idxs.filterNot(str.startsWith("@inheritdoc", _)) /** Does interval `iv` start with given `tag`? */ @@ -190,11 +190,12 @@ object DocStrings { /** Extract the section parameter */ def extractSectionParam(str: String, section: (Int, Int)): String = { - assert(str.substring(section._1).startsWith("@param") || - str.substring(section._1).startsWith("@tparam") || - str.substring(section._1).startsWith("@throws")) + val (beg, _) = section + assert(str.startsWith("@param", beg) || + str.startsWith("@tparam", beg) || + str.startsWith("@throws", beg)) - val start = skipWhitespace(str, skipTag(str, section._1)) + val start = skipWhitespace(str, skipTag(str, beg)) val finish = skipIdent(str, start) str.substring(start, finish) @@ -202,12 +203,13 @@ object DocStrings { /** Extract the section text, except for the tag and comment newlines */ def extractSectionText(str: String, section: (Int, Int)): (Int, Int) = { - if (str.substring(section._1).startsWith("@param") || - str.substring(section._1).startsWith("@tparam") || - str.substring(section._1).startsWith("@throws")) - (skipWhitespace(str, skipIdent(str, skipWhitespace(str, skipTag(str, section._1)))), section._2) + val (beg, end) = section + if (str.startsWith("@param", beg) || + str.startsWith("@tparam", beg) || + str.startsWith("@throws", beg)) + (skipWhitespace(str, skipIdent(str, skipWhitespace(str, skipTag(str, beg)))), end) else - (skipWhitespace(str, skipTag(str, section._1)), section._2) + (skipWhitespace(str, skipTag(str, beg)), end) } /** Cleanup section text */ |