Skip to content

Commit c383acd

Browse files
committed
use base 36 for cuids instead of base10
longest cuid in the core setting is now 3 digits instead of 5 as before. The savings are tiny in total, though.
1 parent f7631eb commit c383acd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/QAST/Block.nqp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class QAST::Block is QAST::Node does QAST::Children {
1111
has %!symbol;
1212
has %!local_debug_map;
1313

14+
my $knowhow := nqp::knowhow().new_type(:repr("P6bigint"));
15+
1416
method new(str :$name, str :$blocktype, *@children, *%options) {
1517
my $node := nqp::create(self);
1618
nqp::bindattr_i($node, QAST::Node, '$!flags', 0);
@@ -44,7 +46,12 @@ class QAST::Block is QAST::Node does QAST::Children {
4446
method cuid($value = NO_VALUE) {
4547
if !($value =:= NO_VALUE) {
4648
# Set ID if we are provided one.
47-
$!cuid := $value;
49+
if nqp::isint($value) {
50+
$!cuid := nqp::base_I(nqp::box_i($value, $knowhow), 36);
51+
}
52+
else {
53+
$!cuid := $value;
54+
}
4855
}
4956
elsif $!cuid {
5057
# If we already have an ID, return it.
@@ -53,7 +60,7 @@ class QAST::Block is QAST::Node does QAST::Children {
5360
else {
5461
# Otherwise, generate one.
5562
$cur_cuid := $cur_cuid + 1;
56-
$!cuid := ~$cur_cuid;
63+
$!cuid := nqp::base_I(nqp::box_i($cur_cuid, $knowhow), 36);
5764
}
5865
}
5966

0 commit comments

Comments
 (0)