Hi Lukasz,

Could you create a PR and discuss the code there? Of course a link to the PR in the dev list is encouraged.

This email format is not really suitable for such discussions especially with 78 character wrapping...

On 5/9/22 13:17, Łukasz Bownik wrote:
Hello.

I refactored the /platform/openide.util/src/org/openide/util/MapFormat.jav
<https://github.com/apache/netbeans/blob/master/platform/openide.util/src/org/openide/util/MapFormat.jav>a
's
*public StringBuffer format(Object pat, StringBuffer result, FieldPosition
fpos) *method.
  The new version
https://github.com/apache/netbeans/pull/4081/commits/22b3fba85982184dba29350b274d1004a08766c5#
is 2 times faster and generates about 50 times less garbage.
All unit tests pass so (hopefully) no behavioral change has been introduced
(as far as tests can tell).

The problem is that another method of this class
*public String processPattern(String newPattern) throws
IllegalArgumentException*
becomes useless now.

I think it should be removed.

My reasoning is the following (based on original implementation)

    - "procesPattern" is never called by any client within code base;
    - calling "processPattern" by clients is useless because:
    - it mainly prepares internal state for execution of "format", which
    then gets overwritten anyway, since "format" calls "preparePattern"
    overwriting effects of previous execution, which makes calling
    "processPattern" by client a no-op;
    - "processPattern" returns the original pattern string with steering
    sequences stripped, so giving it "Hello {name}!" will return "Hello !" -
    which seems useless for clients;

So I suspect that the probability of any *external client *calling this
method is 0. I suspect that this method intention was to be private but it
was made public by accident (it was probably made public temporarily for
testing purposes during developement and then stayed like this).

But.. If we want to keep this API structure unchanged then I could provide
a stubbed implementation like

@deprecated <https://github.com/deprecated>
public String processPattern(String newPattern) throws
IllegalArgumentException {
return newPattern;
}

would it be acceptable?




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Reply via email to