fluo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From keith-turner <...@git.apache.org>
Subject [GitHub] incubator-fluo pull request #825: fixes #823
Date Tue, 25 Apr 2017 04:00:22 GMT
Github user keith-turner commented on a diff in the pull request:

    https://github.com/apache/incubator-fluo/pull/825#discussion_r113102707
  
    --- Diff: modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java ---
    @@ -356,29 +357,44 @@ public static final Bytes of(String s, Charset c) {
       /**
        * Checks if this has the passed prefix
        * 
    -   * @param prefix
    +   * @param prefix is a Bytes object to compare to this
        * @return true or false
    +   * @since 1.1.0
        */
       public boolean startsWith(Bytes prefix) {
    -    for (int i = 0; i < prefix.length; i++) {
    -      if (this.byteAt(i) != prefix.byteAt(i))
    -        return false;
    +    Objects.requireNonNull(prefix, "startWith(Bytes prefix) cannot have null parameter");
    +
    +    if (prefix.length > this.length) {
    +      return false;
    +    } else {
    +      for (int i = 0; i < prefix.length; i++) {
    --- End diff --
    
    To avoid repeatedly adding offsets, could do something like the following.  
    
    ```java
    int end = this.offset + prefix.length;
    for (int i  = this.offset, j = prefix.offset; i < end; i++,j++) 
    ``` 
    
    I am not completely sure about the syntax.


---
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