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

Improve junctions to store only unique eigenstates. #401

Closed
p6rt opened this issue Nov 10, 2008 · 8 comments
Closed

Improve junctions to store only unique eigenstates. #401

p6rt opened this issue Nov 10, 2008 · 8 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Nov 10, 2008

Migrated from rt.perl.org#60444 (status was 'resolved')

Searchable as RT60444$

@p6rt
Copy link
Author

p6rt commented Nov 10, 2008

From @bacek

Hello.

There is attached patch which uniquefy stored eigenstates in
'all'/'any'/'none' junctions.

--
Bacek

@p6rt
Copy link
Author

p6rt commented Nov 10, 2008

From @bacek

junction_uniq.patch
diff --git a/languages/perl6/src/classes/Junction.pir b/languages/perl6/src/classes/Junction.pir
index 5008892..9ae14e9 100644
--- a/languages/perl6/src/classes/Junction.pir
+++ b/languages/perl6/src/classes/Junction.pir
@@ -217,6 +217,12 @@ Return the components of the Junction.
     setattribute junc, '@!eigenstates', eigenstates
     .return (junc)
 .end
+
+.sub '!UNIQUEFY'
+    .param pmc eigenstates :slurpy
+    $P0 = get_hll_global 'infix:==='
+    .return eigenstates.'uniq'($P0)
+.end
     
 .sub '!DISPATCH_JUNCTION'
     .param pmc the_sub
@@ -292,11 +298,13 @@ Return the components of the Junction.
 .sub 'any'
     .param pmc args            :slurpy
     args.'!flatten'()
+    args = '!UNIQUEFY'(args)
     .tailcall '!MAKE_JUNCTION'(JUNCTION_TYPE_ANY, args)
 .end
 
 .sub 'infix:|'
     .param pmc args            :slurpy
+    args = '!UNIQUEFY'(args)
     .tailcall '!MAKE_JUNCTION'(JUNCTION_TYPE_ANY, args)
 .end
 
@@ -325,11 +333,13 @@ Return the components of the Junction.
 .sub 'all'
     .param pmc args            :slurpy
     args.'!flatten'()
+    args = '!UNIQUEFY'(args)
     .tailcall '!MAKE_JUNCTION'(JUNCTION_TYPE_ALL, args)
 .end
 
 .sub 'infix:&'
     .param pmc args            :slurpy
+    args = '!UNIQUEFY'(args)
     .tailcall '!MAKE_JUNCTION'(JUNCTION_TYPE_ALL, args)
 .end
 
@@ -342,6 +352,7 @@ Return the components of the Junction.
 .sub 'none'
     .param pmc args            :slurpy
     args.'!flatten'()
+    args = '!UNIQUEFY'(args)
     .tailcall '!MAKE_JUNCTION'(JUNCTION_TYPE_NONE, args)
 .end
 

@p6rt
Copy link
Author

p6rt commented Nov 10, 2008

From @pmichaud

I'd like to get a clarification from p6l as to whether junction states
should be made unique before applying or rejecting this patch. I'm
particularly curious about one() junctions.

Also, it seems like it would be better to make the list unique inside of
!MAKE_JUNCTION instead of duplicating this code throughout all of the
junction constructors. This would also avoid creating yet another
private function.

Thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Nov 10, 2008

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Nov 10, 2008

From @bacek

Patrick R. Michaud via RT wrote​:

I'd like to get a clarification from p6l as to whether junction states
should be made unique before applying or rejecting this patch. I'm
particularly curious about one() junctions.

Also, it seems like it would be better to make the list unique inside of
!MAKE_JUNCTION instead of duplicating this code throughout all of the
junction constructors. This would also avoid creating yet another
private function.

Revised patch attached.

--
Bacek

@p6rt
Copy link
Author

p6rt commented Nov 10, 2008

From @bacek

junction_uniq2.patch
diff --git a/languages/perl6/src/classes/Junction.pir b/languages/perl6/src/classes/Junction.pir
index 5008892..fbc7b40 100644
--- a/languages/perl6/src/classes/Junction.pir
+++ b/languages/perl6/src/classes/Junction.pir
@@ -214,10 +214,16 @@ Return the components of the Junction.
     $P0 = get_hll_global 'Junction'
     junc = $P0.'new'()
     setattribute junc, '$!type', type
+
+    # Uniquefy eigenstates if possible
+    if type == JUNCTION_TYPE_ONE goto set_eugenstates
+    $P0 = get_hll_global 'infix:==='
+    eigenstates = eigenstates.'uniq'($P0)
+  set_eugenstates:
     setattribute junc, '@!eigenstates', eigenstates
     .return (junc)
 .end
-    
+
 .sub '!DISPATCH_JUNCTION'
     .param pmc the_sub
     .param pmc args            :slurpy

@p6rt
Copy link
Author

p6rt commented Nov 13, 2008

From @pmichaud

After getting confirmation from p6l...

Applied in r32625, thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Nov 13, 2008

@pmichaud - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Nov 13, 2008
@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant