Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maybe a little problem of Message class. #14

Open
AbelSara opened this issue Feb 18, 2020 · 1 comment
Open

maybe a little problem of Message class. #14

AbelSara opened this issue Feb 18, 2020 · 1 comment

Comments

@AbelSara
Copy link

why use this.offset as start point instead of this.offset+this.length

public void writePartialMessageToMessage(Message message, int endIndex){
int startIndexOfPartialMessage = message.offset + endIndex;
int lengthOfPartialMessage = (message.offset + message.length) - endIndex;
System.arraycopy(message.sharedArray, startIndexOfPartialMessage, this.sharedArray, this.offset, lengthOfPartialMessage);
}

@lywhlao
Copy link

lywhlao commented Feb 24, 2020

I am confused by this line as below:
int startIndexOfPartialMessage = message.offset + endIndex;
I think it should be int startIndexOfPartialMessage = endIndex+1 ,because message.offset and endIndex are both address in shareArray And the next partial message index should be endIndex+1 if exists.

    public void writePartialMessageToMessage(Message message, int endIndex) {
//        int startIndexOfPartialMessage = message.offset + endIndex;
        int lengthOfPartialMessage = (message.offset + message.length) - endIndex;
        if (lengthOfPartialMessage > 0) {
            int startIndexOfPartialMessage = endIndex + 1;
            System.arraycopy(message.sharedArray, startIndexOfPartialMessage, this.sharedArray, this.offset, lengthOfPartialMessage);
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants