Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1is7m4-0005CK-K2 for pgsql-jdbc@arkaria.postgresql.org; Thu, 16 Jan 2020 16:13:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1is7m2-0000Hh-LZ for pgsql-jdbc@arkaria.postgresql.org; Thu, 16 Jan 2020 16:13:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1is7m2-0000HY-3p for pgsql-jdbc@lists.postgresql.org; Thu, 16 Jan 2020 16:13:34 +0000 Received: from out-3.smtp.github.com ([192.30.252.194]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1is7lv-0001KZ-AI for pgsql-jdbc@lists.postgresql.org; Thu, 16 Jan 2020 16:13:31 +0000 Date: Thu, 16 Jan 2020 08:13:26 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com; s=pf2014; t=1579191206; bh=kPZaUV92zKVqH3zmVhfbVeoqEyaADVBc92my8rxJzXI=; h=Date:From:To:Subject:From; b=1urxsYGg0NKHtCnln84+oSQ7a8rFWmznGZlxXCWtta2drogaPDyBHZZeHTj91Plsj XbSOyuVUbAk9YwL9tkNlYQBoBPbZNaK/S00HZvVLlShjgGeav0Vva+Atu2czSXwuT+ ICKgFzEHq14fJMSnSUaEWVLQt36DkCZATxjobss0= From: Brett Okken To: pgsql-jdbc@lists.postgresql.org Message-ID: Subject: [pgjdbc/pgjdbc] c84e62: Utf 8 encoding optimizations (#1444) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Approved: 58GruLoMopuc X-GitHub-Recipient-Address: pgsql-jdbc@lists.postgresql.org X-Auto-Response-Suppress: All List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Branch: refs/heads/master Home: https://github.com/pgjdbc/pgjdbc Commit: c84e62efa5b98323562753e45fbf0d974eaca483 https://github.com/pgjdbc/pgjdbc/commit/c84e62efa5b98323562753e45fbf0d974eaca483 Author: Brett Okken Date: 2020-01-16 (Thu, 16 Jan 2020) Changed paths: A pgjdbc/src/main/java/org/postgresql/core/ByteOptimizedUTF8Encoder.java A pgjdbc/src/main/java/org/postgresql/core/CharOptimizedUTF8Encoder.java M pgjdbc/src/main/java/org/postgresql/core/Encoding.java A pgjdbc/src/main/java/org/postgresql/core/OptimizedUTF8Encoder.java R pgjdbc/src/main/java/org/postgresql/core/UTF8Encoding.java A pgjdbc/src/test/java/org/postgresql/core/UTF8EncodingTest.java M pgjdbc/src/test/java/org/postgresql/test/jdbc2/Jdbc2TestSuite.java Log Message: ----------- Utf 8 encoding optimizations (#1444) * fix: Correct typo weather to whether * misc: Change internal Encoding.testAsciiNumbers(...) to be static * perf: Enhance Encoding constructor to allow skipping of ASCII number compatibility test Adds a two parameter constructor to Encoding to allow sub classes to specify whether their known ASCII compatability so as to skip testing. The only usage of it is the UTF8Encoding which is changed to use the new constructor. * fix: limit size of char[] for utf-8 decoding Also optimize for java 9+ byte[] backed strings * fix: limit size of char[] for utf-8 decoding address style issues * fix: limit size of char[] for utf-8 decoding address style issues * fix: limit size of char[] for utf-8 decoding use existing JavaVersion enum to pick implementation add unit test string values more consistency between byte and char based implementations * fix: limit size of char[] for utf-8 decoding fix backwards comparison add more strings to unit test * fix: limit size of char[] for utf-8 decoding Move to using new String(byte[], int, int, Charset) rather than custom decoding for jre newer than 1.8. * fix: limit size of char[] for utf-8 decoding Back to custom utf-8 decoding for performance gains while validating * javadoc * put test back into test suite * avoid creating an unnecessary `char[]` when growing cached array Co-authored-by: Sehrope Sarkuni Co-authored-by: Dave Cramer