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

[Java] Generate put CharSequence methods for ASCII encoded fields #547

Merged
merged 1 commit into from
Mar 19, 2018

Conversation

zyulyaev
Copy link
Contributor

This PR allows to set ASCII encoded char array fields with any class implementing CharSequence, not only with Strings. It helps writing GC-free code without handling byte arrays. One for example can pass StringBuilder as an argument which can be shared between invocations.

@tmontgomery tmontgomery merged commit d6dfb92 into real-logic:master Mar 19, 2018
@juddgaddie
Copy link
Contributor

@zyulyaev is there any reason why you did not include something similar on the Decoder side that takes an Appendable such as StringBuilder
eg
public void getMyValue(Appendable val)

@zyulyaev
Copy link
Contributor Author

@juddgaddie not really, I just added only what I needed.
Regarding Appendable to Decoder, I would rather added a method that returns a wrapper object implementing CharSequence interface, similar to how currently composite decoders work.
eg

private final MyValueWrapper myValueWrapper = new MyValueWrapper();

public CharSequence myValueWrapper() {
    return myValueWrapper;
}

private class MyValueWrapper implements CharSequence {
    public int length() {
        int len;
        for (len = 0; charAt(len) != 0; len++);
        return len;
    }

    public char charAt(int index) {
        final int pos = this.offset + <offset> + index;
        return (char) buffer.getByte(pos);
    }
}

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

Successfully merging this pull request may close these issues.

None yet

3 participants