Skip to content

Commit

Permalink
Encoding header negotiation deduplication and CharSequences cleanup (#…
Browse files Browse the repository at this point in the history
…1311)

* Encoding header negotiation deduplication and CharSequences cleanup
  • Loading branch information
tkountis authored Jan 31, 2021
1 parent 75d3822 commit 1645999
Show file tree
Hide file tree
Showing 64 changed files with 792 additions and 567 deletions.
2 changes: 1 addition & 1 deletion servicetalk-benchmarks/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2018-2019 Apple Inc. and the ServiceTalk project authors
* Copyright © 2018-2019, 2021 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2019 Apple Inc. and the ServiceTalk project authors
* Copyright © 2019, 2021 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,8 +34,8 @@

import java.util.ArrayDeque;

import static io.servicetalk.buffer.api.CharSequences.newAsciiString;
import static io.servicetalk.buffer.api.ReadOnlyBufferAllocators.DEFAULT_RO_ALLOCATOR;
import static io.servicetalk.http.api.CharSequences.newAsciiString;
import static io.servicetalk.http.api.DefaultHttpHeadersFactory.INSTANCE;
import static io.servicetalk.http.api.HttpHeaderNames.CONTENT_LENGTH;
import static io.servicetalk.http.api.HttpHeaderNames.CONTENT_TYPE;
Expand Down
3 changes: 3 additions & 0 deletions servicetalk-buffer-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"
dependencies {
implementation project(":servicetalk-annotations")

implementation "com.google.code.findbugs:jsr305:$jsr305Version"

testImplementation "junit:junit:$junitVersion"
testImplementation "org.hamcrest:hamcrest-library:$hamcrestVersion"
testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"
testFixturesImplementation "org.hamcrest:hamcrest-library:$hamcrestVersion"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2018 Apple Inc. and the ServiceTalk project authors
* Copyright © 2018, 2021 Apple Inc. and the ServiceTalk project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,20 +28,16 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.servicetalk.http.api;

import io.servicetalk.buffer.api.Buffer;
import io.servicetalk.buffer.api.ByteProcessor;
package io.servicetalk.buffer.api;

import java.nio.ByteOrder;

import static io.servicetalk.buffer.api.EmptyBuffer.EMPTY_BUFFER;
import static io.servicetalk.http.api.CharSequences.contentEqualsIgnoreCaseUnknownTypes;
import static io.servicetalk.http.api.CharSequences.contentEqualsUnknownTypes;
import static io.servicetalk.buffer.api.CharSequences.contentEqualsIgnoreCaseUnknownTypes;
import static io.servicetalk.buffer.api.CharSequences.contentEqualsUnknownTypes;
import static java.nio.charset.StandardCharsets.US_ASCII;

final class AsciiBuffer implements CharSequence {
static final CharSequence EMPTY_ASCII_BUFFER = new AsciiBuffer(EMPTY_BUFFER);
static final CharSequence EMPTY_ASCII_BUFFER = new AsciiBuffer(EmptyBuffer.EMPTY_BUFFER);
private static final boolean BIG_ENDIAN_NATIVE_ORDER = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN;
// constants borrowed from murmur3
private static final int HASH_CODE_ASCII_SEED = 0xc2b2ae35;
Expand Down Expand Up @@ -124,6 +120,7 @@ int indexOf(char ch, int start) {
/**
* Iterates over the readable bytes of this buffer with the specified {@code processor} in ascending order.
*
* @param visitor the {@link ByteProcessor} visitor of each element.
* @return {@code -1} if the processor iterated to or beyond the end of the readable bytes.
* The last-visited index If the {@link ByteProcessor#process(byte)} returned {@code false}.
*/
Expand Down
Loading

0 comments on commit 1645999

Please sign in to comment.