]> Repositorios git - scryer-prolog.git/commitdiff
use Fixnums for bytes in hashing.
authorMarkus Triska <[email protected]>
Tue, 19 May 2020 14:43:44 +0000 (16:43 +0200)
committerMarkus Triska <[email protected]>
Tue, 19 May 2020 14:43:44 +0000 (16:43 +0200)
Suggested by @notoria in #533. Many thanks!

src/prolog/machine/system_calls.rs

index 847d4e6d1c1c899fbfc7a43d8fe0ec8eb3b9e32f..fe90950d71622590f6eb73fc402b7fe6785f82d5 100644 (file)
@@ -5224,25 +5224,25 @@ impl MachineState {
                         match algorithm_str  {
                           "sha3_224" =>   { let mut context = Sha3_224::new();
                                             context.input(&bytes);
-                                            Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::Integer(Rc::new(Integer::from(*b)))))) }
+                                            Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::from(Addr::Fixnum(*b as isize))))) }
                           "sha3_256" =>   { let mut context = Sha3_256::new();
                                             context.input(&bytes);
-                                            Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::Integer(Rc::new(Integer::from(*b)))))) }
+                                            Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::from(Addr::Fixnum(*b as isize))))) }
                           "sha3_384" =>   { let mut context = Sha3_384::new();
                                             context.input(&bytes);
-                                            Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::Integer(Rc::new(Integer::from(*b)))))) }
+                                            Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::from(Addr::Fixnum(*b as isize))))) }
                           "sha3_512" =>   { let mut context = Sha3_512::new();
                                             context.input(&bytes);
-                                            Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::Integer(Rc::new(Integer::from(*b)))))) }
+                                            Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::from(Addr::Fixnum(*b as isize))))) }
                           "blake2s256" => { let mut context = Blake2s::new();
                                             context.input(&bytes);
-                                            Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::Integer(Rc::new(Integer::from(*b)))))) }
+                                            Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::from(Addr::Fixnum(*b as isize))))) }
                           "blake2b512" => { let mut context = Blake2b::new();
                                             context.input(&bytes);
-                                            Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::Integer(Rc::new(Integer::from(*b)))))) }
+                                            Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::from(Addr::Fixnum(*b as isize))))) }
                           "ripemd160" =>  { let mut context = Ripemd160::new();
                                             context.input(&bytes);
-                                            Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::Integer(Rc::new(Integer::from(*b)))))) }
+                                            Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::from(Addr::Fixnum(*b as isize))))) }
                           _ => { let ints = digest::digest(
                                                 match algorithm_str {
                                                    "sha256" =>     { &digest::SHA256 }