On Sat, 25 May 2024 11:06:51 GMT, Vicente Romero <vrom...@openjdk.org> wrote:

>> If the javadoc comment contains a (Markdown) link like:
>> 
>> [java.util.Arrays#asList(Object[])]
>> 
>> 
>> The transformer that converts this link into the Javadoc link will not find 
>> the reference, as it is looking for `java.util.Arrays#asList(Object[])` 
>> (note the missing escapes), which is not present in the original text.
>> 
>> This patch tries to fix that by permitting optional escapes for all 
>> escapable character when searching for the reference, in case the literal 
>> search fails. This is done using regexp, although could presumably be done 
>> using a manual search.
>
> src/jdk.internal.md/share/classes/jdk/internal/markdown/MarkdownTransformer.java
>  line 858:
> 
>> 856:                     for (char c : ref.toCharArray()) {
>> 857:                         if (Escaping.ESCAPABLE.indexOf(c) >= 0) {
>> 858:                             pattern.append("\\\\?");
> 
> suggestion, dunno how critical is this code but regex usually are a tax on 
> performance, I would consider not using them

Sorry for the belated answer. Yes, regexps are usually not very performant, but 
it is only happening when the exact match fails. And, hopefully, the regexp 
should not be too difficult to handle. I was considering writing the search by 
hand, and I can, but it seems like a lot of code to handle a case like this. I 
can write the search manually, though.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/19387#discussion_r1617730688

Reply via email to