@@ -390,13 +390,12 @@ defmodule Base do
390
390
end
391
391
392
392
defp unquote ( decode_name ) ( char ) do
393
- try do
394
- elem ( { unquote_splicing ( decoded ) } , char - unquote ( min ) )
395
- rescue
396
- _ -> bad_character! ( char )
397
- else
398
- nil -> bad_character! ( char )
399
- char -> char
393
+ index = char - unquote ( min )
394
+
395
+ cond do
396
+ index not in 0 .. unquote ( length ( decoded ) - 1 ) -> bad_character! ( char )
397
+ new_char = elem ( { unquote_splicing ( decoded ) } , index ) -> new_char
398
+ true -> bad_character! ( char )
400
399
end
401
400
end
402
401
@@ -859,13 +858,12 @@ defmodule Base do
859
858
end
860
859
861
860
defp unquote ( decode_name ) ( char ) do
862
- try do
863
- elem ( { unquote_splicing ( decoded ) } , char - unquote ( min ) )
864
- rescue
865
- _ -> bad_character! ( char )
866
- else
867
- nil -> bad_character! ( char )
868
- char -> char
861
+ index = char - unquote ( min )
862
+
863
+ cond do
864
+ index not in 0 .. unquote ( length ( decoded ) - 1 ) -> bad_character! ( char )
865
+ new_char = elem ( { unquote_splicing ( decoded ) } , index ) -> new_char
866
+ true -> bad_character! ( char )
869
867
end
870
868
end
871
869
@@ -1508,13 +1506,12 @@ defmodule Base do
1508
1506
end
1509
1507
1510
1508
defp unquote ( decode_name ) ( char ) do
1511
- try do
1512
- elem ( { unquote_splicing ( decoded ) } , char - unquote ( min ) )
1513
- rescue
1514
- _ -> bad_character! ( char )
1515
- else
1516
- nil -> bad_character! ( char )
1517
- char -> char
1509
+ index = char - unquote ( min )
1510
+
1511
+ cond do
1512
+ index not in 0 .. unquote ( length ( decoded ) - 1 ) -> bad_character! ( char )
1513
+ new_char = elem ( { unquote_splicing ( decoded ) } , index ) -> new_char
1514
+ true -> bad_character! ( char )
1518
1515
end
1519
1516
end
1520
1517
0 commit comments