From a6634ede60485017b1a0dd077d064568e06c76e2 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Tue, 27 Feb 2024 16:38:11 +0300 Subject: [PATCH 01/11] #2716: tuple optimization --- eo-runtime/src/main/eo/org/eolang/tuple.eo | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/eo-runtime/src/main/eo/org/eolang/tuple.eo b/eo-runtime/src/main/eo/org/eolang/tuple.eo index 9ef8d40931..01503d79a2 100644 --- a/eo-runtime/src/main/eo/org/eolang/tuple.eo +++ b/eo-runtime/src/main/eo/org/eolang/tuple.eo @@ -57,10 +57,17 @@ index.lt 0 index.gte len error "Given index is out of tuple bounds" - if. - index.lt (len.plus -1) - ^.head.at index - ^.tail + ^.at-without-checks index + + # Takes element from the tuple without checking i. + # i must be less than len and greater or equal 0. + # This is faster than ^.at. + [i] > at-without-checks + i > idx! + if. > @ + i.lt head.length + ^.head.at-without-checks i + ^.tail # Create a new tuple with this element added to the end of it. [x] > with From 6b7a63adcc477057276976d2996187fba673c0fc Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Tue, 27 Feb 2024 16:40:58 +0300 Subject: [PATCH 02/11] #2716: tuple optimization --- eo-runtime/src/main/eo/org/eolang/tuple.eo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eo-runtime/src/main/eo/org/eolang/tuple.eo b/eo-runtime/src/main/eo/org/eolang/tuple.eo index 01503d79a2..354ca204d8 100644 --- a/eo-runtime/src/main/eo/org/eolang/tuple.eo +++ b/eo-runtime/src/main/eo/org/eolang/tuple.eo @@ -60,8 +60,8 @@ ^.at-without-checks index # Takes element from the tuple without checking i. - # i must be less than len and greater or equal 0. - # This is faster than ^.at. + # i must be less than length and greater or equal 0. + # This is faster than at. [i] > at-without-checks i > idx! if. > @ From 668f7303c62d71dbfb300d5c0ffa979bc5fd6657 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Tue, 27 Feb 2024 16:53:28 +0300 Subject: [PATCH 03/11] #2716: added tests --- eo-runtime/src/test/eo/org/eolang/tuple-tests.eo | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/eo-runtime/src/test/eo/org/eolang/tuple-tests.eo b/eo-runtime/src/test/eo/org/eolang/tuple-tests.eo index 4172211b44..2826de7d90 100644 --- a/eo-runtime/src/test/eo/org/eolang/tuple-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/tuple-tests.eo @@ -172,6 +172,22 @@ a.at 0 3 +# Test +[] > at-without-checks-with-first-element + eq. > @ + at. + * 100 101 102 + 0 + 100 + +# Test +[] > at-without-checks-with-last-element + eq. > @ + at. + * 100 101 102 + 2 + 102 + # Test. [] > tuple-empty-fluent-with-indented-keyword tuple From 4cbe4c22ebf276b2b81fdaea16240f1d781ba66b Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Tue, 27 Feb 2024 17:16:39 +0300 Subject: [PATCH 04/11] #2716: idx --- eo-runtime/src/main/eo/org/eolang/tuple.eo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eo-runtime/src/main/eo/org/eolang/tuple.eo b/eo-runtime/src/main/eo/org/eolang/tuple.eo index 354ca204d8..ac8f01ad3e 100644 --- a/eo-runtime/src/main/eo/org/eolang/tuple.eo +++ b/eo-runtime/src/main/eo/org/eolang/tuple.eo @@ -65,8 +65,8 @@ [i] > at-without-checks i > idx! if. > @ - i.lt head.length - ^.head.at-without-checks i + idx.lt head.length + ^.head.at-without-checks idx ^.tail # Create a new tuple with this element added to the end of it. From d3bcd1e27c893e1e6182d886a8db4651d1922b4f Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Tue, 27 Feb 2024 17:40:54 +0300 Subject: [PATCH 05/11] #2716: placed it inside at. --- eo-runtime/src/main/eo/org/eolang/tuple.eo | 18 +++++++++--------- .../src/test/eo/org/eolang/tuple-tests.eo | 10 ++++++---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/eo-runtime/src/main/eo/org/eolang/tuple.eo b/eo-runtime/src/main/eo/org/eolang/tuple.eo index ac8f01ad3e..f7d9d5014e 100644 --- a/eo-runtime/src/main/eo/org/eolang/tuple.eo +++ b/eo-runtime/src/main/eo/org/eolang/tuple.eo @@ -59,15 +59,15 @@ error "Given index is out of tuple bounds" ^.at-without-checks index - # Takes element from the tuple without checking i. - # i must be less than length and greater or equal 0. - # This is faster than at. - [i] > at-without-checks - i > idx! - if. > @ - idx.lt head.length - ^.head.at-without-checks idx - ^.tail + # Takes element from the tuple without checking i. + # i must be less than length and greater or equal 0. + # This is faster than at. + [i] > at-without-checks + i > idx! + if. > @ + idx.lt head.length + ^.^.head.at.at-without-checks idx + ^.^.tail # Create a new tuple with this element added to the end of it. [x] > with diff --git a/eo-runtime/src/test/eo/org/eolang/tuple-tests.eo b/eo-runtime/src/test/eo/org/eolang/tuple-tests.eo index 2826de7d90..85dd8fff86 100644 --- a/eo-runtime/src/test/eo/org/eolang/tuple-tests.eo +++ b/eo-runtime/src/test/eo/org/eolang/tuple-tests.eo @@ -175,16 +175,18 @@ # Test [] > at-without-checks-with-first-element eq. > @ - at. - * 100 101 102 + at-without-checks. + at. + * 100 101 102 0 100 # Test [] > at-without-checks-with-last-element eq. > @ - at. - * 100 101 102 + at-without-checks. + at. + * 100 101 102 2 102 From 5d97719fa0d37d6a833a084b9f714521801c167f Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Tue, 27 Feb 2024 17:42:32 +0300 Subject: [PATCH 06/11] #2716: placed it inside at. --- eo-runtime/src/main/eo/org/eolang/tuple.eo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-runtime/src/main/eo/org/eolang/tuple.eo b/eo-runtime/src/main/eo/org/eolang/tuple.eo index f7d9d5014e..eda84e69ab 100644 --- a/eo-runtime/src/main/eo/org/eolang/tuple.eo +++ b/eo-runtime/src/main/eo/org/eolang/tuple.eo @@ -57,7 +57,7 @@ index.lt 0 index.gte len error "Given index is out of tuple bounds" - ^.at-without-checks index + ^.at.at-without-checks index # Takes element from the tuple without checking i. # i must be less than length and greater or equal 0. From a04823da59d48c4e3490850ca2b20fc8ac54d3b0 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Tue, 27 Feb 2024 18:19:51 +0300 Subject: [PATCH 07/11] #2716: Removed commentary that this is faster --- eo-runtime/src/main/eo/org/eolang/tuple.eo | 1 - 1 file changed, 1 deletion(-) diff --git a/eo-runtime/src/main/eo/org/eolang/tuple.eo b/eo-runtime/src/main/eo/org/eolang/tuple.eo index eda84e69ab..ab96988de6 100644 --- a/eo-runtime/src/main/eo/org/eolang/tuple.eo +++ b/eo-runtime/src/main/eo/org/eolang/tuple.eo @@ -61,7 +61,6 @@ # Takes element from the tuple without checking i. # i must be less than length and greater or equal 0. - # This is faster than at. [i] > at-without-checks i > idx! if. > @ From f764cea9b51ddca71424c6bbf9a3c260e7f0a341 Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Tue, 27 Feb 2024 18:37:54 +0300 Subject: [PATCH 08/11] #2716: Removed commentary that this is faster --- eo-runtime/src/main/eo/org/eolang/tuple.eo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-runtime/src/main/eo/org/eolang/tuple.eo b/eo-runtime/src/main/eo/org/eolang/tuple.eo index ab96988de6..2c0ff7e05a 100644 --- a/eo-runtime/src/main/eo/org/eolang/tuple.eo +++ b/eo-runtime/src/main/eo/org/eolang/tuple.eo @@ -57,7 +57,7 @@ index.lt 0 index.gte len error "Given index is out of tuple bounds" - ^.at.at-without-checks index + at-without-checks index # Takes element from the tuple without checking i. # i must be less than length and greater or equal 0. From eb1968abf5113ac214f68ccf02284f5105648d1f Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Wed, 28 Feb 2024 12:43:55 +0300 Subject: [PATCH 09/11] #2716: Updated commentary --- eo-runtime/src/main/eo/org/eolang/tuple.eo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eo-runtime/src/main/eo/org/eolang/tuple.eo b/eo-runtime/src/main/eo/org/eolang/tuple.eo index 2c0ff7e05a..6b3277daf0 100644 --- a/eo-runtime/src/main/eo/org/eolang/tuple.eo +++ b/eo-runtime/src/main/eo/org/eolang/tuple.eo @@ -59,8 +59,8 @@ error "Given index is out of tuple bounds" at-without-checks index - # Takes element from the tuple without checking i. - # i must be less than length and greater or equal 0. + # Takes element from the tuple without index validation. + # Here i must be an object that can be comparable with int using lt attribute. [i] > at-without-checks i > idx! if. > @ From 760b2a32ce4a4a3f2a0eab210e339814802517bf Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Wed, 28 Feb 2024 14:37:05 +0300 Subject: [PATCH 10/11] #2716: quotes --- eo-runtime/src/main/eo/org/eolang/tuple.eo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-runtime/src/main/eo/org/eolang/tuple.eo b/eo-runtime/src/main/eo/org/eolang/tuple.eo index 6b3277daf0..9a795f82b0 100644 --- a/eo-runtime/src/main/eo/org/eolang/tuple.eo +++ b/eo-runtime/src/main/eo/org/eolang/tuple.eo @@ -60,7 +60,7 @@ at-without-checks index # Takes element from the tuple without index validation. - # Here i must be an object that can be comparable with int using lt attribute. + # Here "i" must be an object that can be comparable with "int" using "lt" attribute. [i] > at-without-checks i > idx! if. > @ From ce19727052e6eca901cc4593e47d68ee04988edd Mon Sep 17 00:00:00 2001 From: levBagryansky <28lev11@gmail.com> Date: Wed, 28 Feb 2024 16:02:43 +0300 Subject: [PATCH 11/11] #2716: brackets --- eo-runtime/src/main/eo/org/eolang/tuple.eo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-runtime/src/main/eo/org/eolang/tuple.eo b/eo-runtime/src/main/eo/org/eolang/tuple.eo index 9a795f82b0..8c38ba3781 100644 --- a/eo-runtime/src/main/eo/org/eolang/tuple.eo +++ b/eo-runtime/src/main/eo/org/eolang/tuple.eo @@ -60,7 +60,7 @@ at-without-checks index # Takes element from the tuple without index validation. - # Here "i" must be an object that can be comparable with "int" using "lt" attribute. + # Here `i` must be an object that can be comparable with `int` using `lt` attribute. [i] > at-without-checks i > idx! if. > @