Run of fresh-releases for golang-github-martinlindhe-base36

Merge these changes:

Summary

Merged new upstream version: 1.1.0 (was: 1.0.0).

Diff

diff --git a/base36.go b/base36.go
index 2158458..8e4f3dc 100644
--- a/base36.go
+++ b/base36.go
@@ -1,7 +1,6 @@
 package base36
 
 import (
-	"math"
 	"math/big"
 	"strings"
 )
@@ -13,21 +12,57 @@ var (
 		'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
 		'U', 'V', 'W', 'X', 'Y', 'Z'}
 
-	index = map[byte]int{
-		'0': 0, '1': 1, '2': 2, '3': 3, '4': 4,
-		'5': 5, '6': 6, '7': 7, '8': 8, '9': 9,
-		'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14,
-		'F': 15, 'G': 16, 'H': 17, 'I': 18, 'J': 19,
-		'K': 20, 'L': 21, 'M': 22, 'N': 23, 'O': 24,
-		'P': 25, 'Q': 26, 'R': 27, 'S': 28, 'T': 29,
-		'U': 30, 'V': 31, 'W': 32, 'X': 33, 'Y': 34,
-		'Z': 35,
-		'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14,
-		'f': 15, 'g': 16, 'h': 17, 'i': 18, 'j': 19,
-		'k': 20, 'l': 21, 'm': 22, 'n': 23, 'o': 24,
-		'p': 25, 'q': 26, 'r': 27, 's': 28, 't': 29,
-		'u': 30, 'v': 31, 'w': 32, 'x': 33, 'y': 34,
-		'z': 35,
+	//index = map[byte]int{
+	//	'0': 0, '1': 1, '2': 2, '3': 3, '4': 4,
+	//	'5': 5, '6': 6, '7': 7, '8': 8, '9': 9,
+	//	'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14,
+	//	'F': 15, 'G': 16, 'H': 17, 'I': 18, 'J': 19,
+	//	'K': 20, 'L': 21, 'M': 22, 'N': 23, 'O': 24,
+	//	'P': 25, 'Q': 26, 'R': 27, 'S': 28, 'T': 29,
+	//	'U': 30, 'V': 31, 'W': 32, 'X': 33, 'Y': 34,
+	//	'Z': 35,
+	//	'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14,
+	//	'f': 15, 'g': 16, 'h': 17, 'i': 18, 'j': 19,
+	//	'k': 20, 'l': 21, 'm': 22, 'n': 23, 'o': 24,
+	//	'p': 25, 'q': 26, 'r': 27, 's': 28, 't': 29,
+	//	'u': 30, 'v': 31, 'w': 32, 'x': 33, 'y': 34,
+	//	'z': 35,
+	//}
+	uint8Index = []uint64{
+		0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
+		3, 4, 5, 6, 7, 8, 9, 0, 0, 0,
+		0, 0, 0, 0, 10, 11, 12, 13, 14,
+		15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+		25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+		35, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13,
+		14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+		24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
+		34, 35, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, // 256
+	}
+	pow36Index = []uint64{
+		1, 36, 1296, 46656, 1679616, 60466176,
+		2176782336, 78364164096, 2821109907456,
+		101559956668416, 3656158440062976,
+		131621703842267136, 4738381338321616896,
+		9223372036854775808,
 	}
 )
 
@@ -35,20 +70,27 @@ var (
 func Encode(value uint64) string {
 	var res [16]byte
 	var i int
-	for i = len(res) - 1; value != 0; i-- {
+	for i = len(res) - 1; ; i-- {
 		res[i] = base36[value%36]
 		value /= 36
+		if value == 0 {
+			break
+		}
 	}
-	return string(res[i+1:])
+
+	return string(res[i:])
 }
 
 // Decode decodes a base36-encoded string.
 func Decode(s string) uint64 {
+	if len(s) > 13 {
+		s = s[:12]
+	}
 	res := uint64(0)
 	l := len(s) - 1
-	for idx := range s {
+	for idx := 0; idx < len(s); idx++ {
 		c := s[l-idx]
-		res += uint64(index[c]) * uint64(math.Pow(36, float64(idx)))
+		res += uint8Index[c] * pow36Index[idx]
 	}
 	return res
 }
diff --git a/base36_test.go b/base36_test.go
index 6a6b2a4..5f1e13e 100644
--- a/base36_test.go
+++ b/base36_test.go
@@ -12,7 +12,7 @@ var raw = []uint64{0, 50, 100, 999, 1000, 1111, 5959, 99999,
 	123456789, 5481594952936519619, math.MaxInt64 / 2048, math.MaxInt64 / 512,
 	math.MaxInt64, math.MaxUint64}
 
-var encoded = []string{"", "1E", "2S", "RR", "RS", "UV", "4LJ", "255R",
+var encoded = []string{"0", "1E", "2S", "RR", "RS", "UV", "4LJ", "255R",
 	"21I3V9", "15N9Z8L3AU4EB", "18CE53UN18F", "4XDKKFEK4XR",
 	"1Y2P0IJ32E8E7", "3W5E11264SGSF"}
 
diff --git a/debian/changelog b/debian/changelog
index 3ea5eca..499b68f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+golang-github-martinlindhe-base36 (1.1.0-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Thu, 10 Mar 2022 03:57:12 -0000
+
 golang-github-martinlindhe-base36 (1.0.0-2) unstable; urgency=medium
 
   * Team upload.
diff --git a/example_test.go b/example_test.go
index 12250e9..f4596ab 100644
--- a/example_test.go
+++ b/example_test.go
@@ -4,6 +4,7 @@ import (
 	"fmt"
 
 	"github.com/martinlindhe/base36"
+
 )
 
 func ExampleEncode() {

Publish Blockers

  • ☑ run was successful
  • ☑ package has not been removed from the archive
  • ☑ command has not changed
  • ☒ not yet reviewed, but review needed
  • ☑ 0 publish attempts so far.not currently attempting to back off
  • ☒ merge proposals for the package maintainer are currently being rate-limited (open: 549, max open: 300)
  • ☑ change set 9e9ffba3-3d0f-4a92-907a-0f88fd33b6d3 is ready

Resulting package

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases golang-github-martinlindhe-base36-dev

Lintian Result

Full worker log Full build log