brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grkvlt <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request: Make entity ids lowercase
Date Tue, 24 May 2016 14:31:39 GMT
Github user grkvlt commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/134#discussion_r64402022
  
    --- Diff: utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java ---
    @@ -87,29 +87,34 @@
          * in general this is preferable to base64 as is more portable,
          * can be used throughout javascript (as ID's which don't allow +)
          * or as java identifiers (which don't allow numbers in the first char)
    -     **/
    -    public static String makeRandomId(int l) {
    -        //this version is 30-50% faster than the old double-based one, 
    -        //which computed a random every 3 turns --
    -        //takes about 600 ns to do id of len 10, compared to 10000 ns for old version
[on 1.6ghz machine]
    -        if (l<=0) return "";
    +     * <p>
    +     * <b>NOTE</b> This version is 30-50% faster than the old double-based
one,
    +     * which computed a random every 3 turns -- takes about 600 ns to do id
    +     * of len 10, compared to 10000 ns for old version [on 1.6ghz machine]
    +     */
    +    public static String makeRandomId(int l, String validStartChars, String validNonStartChars)
{
    +        if (l <= 0) return "";
             char[] id = new char[l];
    -        int d = random.nextInt( (26+26) * (26+26+10) * (26+26+10) * (26+26+10) * (26+26+10));
    +        int s = validStartChars.length();
    +        int n = validNonStartChars.length();
    +        int d = random.nextInt(s * n * n * n * n);
    --- End diff --
    
    I'm going to use groups of 4 characters, and will limit the character set strings to a
length of 128 maximum. Do you think it should error on too many characters, or silently truncate
to the first 128?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message