You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2021/09/11 15:15:53 UTC

[httpcomponents-core] branch 5.1.x updated: More efficient implementation of #appendPathSegments in URIBuilder

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch 5.1.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git


The following commit(s) were added to refs/heads/5.1.x by this push:
     new e220221  More efficient implementation of #appendPathSegments in URIBuilder
e220221 is described below

commit e2202217c99d8c033fbb9bbdafef47920bf81292
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Sat Sep 11 17:08:16 2021 +0200

    More efficient implementation of #appendPathSegments in URIBuilder
---
 httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java
index 6c4ff48..0c8aa8c 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java
@@ -570,9 +570,12 @@ public class URIBuilder {
      */
     public URIBuilder appendPathSegments(final List<String> pathSegments) {
         if (pathSegments != null && !pathSegments.isEmpty()) {
-            final List<String> segments = new ArrayList<>(getPathSegments());
-            segments.addAll(pathSegments);
-            setPathSegments(segments);
+            if (this.pathSegments == null) {
+                this.pathSegments = new ArrayList<>();
+            }
+            this.pathSegments.addAll(pathSegments);
+            this.encodedSchemeSpecificPart = null;
+            this.encodedPath = null;
         }
         return this;
     }