Skip to content

Commit c61a4e0

Browse files
authored
chore: remove useless casts (#68)
1 parent c487618 commit c61a4e0

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

src/_string_tools/slice_packed_field.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ pub fn slice_fields<let InputFields: u32, let OutputFields: u32>(
756756
let use_previous_for_last_limb: Field = extra_head_section + bytes_fit_into_limb;
757757

758758
// 1, 132.5
759-
let mut index_of_overflow_limb = start_index + num_whole_limbs + 1;
759+
let index_of_overflow_limb = start_index + num_whole_limbs + 1;
760760
// 2, 134.5
761761
let last_limb_from_data = data[index_of_overflow_limb as u32];
762762
// 2, 136.5

src/_table_generation/make_tables.nr

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ unconstrained fn make_token_validation_table() -> [Field; NUM_TOKENS * NUM_TOKEN
288288
let mut flattened_flags: [Field; NUM_TOKENS * NUM_TOKENS * 3] =
289289
[0; NUM_TOKENS * NUM_TOKENS * 3];
290290
let NN = (NUM_TOKENS * NUM_TOKENS);
291-
for j in 0..NUM_TOKENS as u32 {
292-
for k in 0..NUM_TOKENS as u32 {
291+
for j in 0..NUM_TOKENS {
292+
for k in 0..NUM_TOKENS {
293293
flattened_flags[OBJECT_LAYER * NN + j * NUM_TOKENS + k] = object_layer_flags[j][k];
294294
flattened_flags[ARRAY_LAYER * NN + j * NUM_TOKENS + k] = array_layer_flags[j][k];
295295
flattened_flags[SINGLE_VALUE_LAYER * NN + j * NUM_TOKENS + k] =
@@ -467,20 +467,20 @@ unconstrained fn generate_token_flags_table() -> [Field; NUM_TOKENS * 2] {
467467
numeric_flags.new_context = ARRAY_LAYER as Field;
468468
literal_flags.new_context = ARRAY_LAYER as Field;
469469

470-
flags[NUM_TOKENS + (NO_TOKEN as u32)] = no_token_flags;
471-
flags[NUM_TOKENS + (BEGIN_OBJECT_TOKEN as u32)] = begin_object_flags;
472-
flags[NUM_TOKENS + (END_OBJECT_TOKEN as u32)] = end_object_flags;
473-
flags[NUM_TOKENS + (BEGIN_ARRAY_TOKEN as u32)] = begin_array_flags;
474-
flags[NUM_TOKENS + (END_ARRAY_TOKEN as u32)] = end_array_flags;
475-
flags[NUM_TOKENS + (KEY_SEPARATOR_TOKEN as u32)] = no_token_flags;
476-
flags[NUM_TOKENS + (VALUE_SEPARATOR_TOKEN as u32)] = no_token_flags;
477-
flags[NUM_TOKENS + (STRING_TOKEN as u32)] = string_flags;
478-
flags[NUM_TOKENS + (NUMERIC_TOKEN as u32)] = numeric_flags;
479-
flags[NUM_TOKENS + (LITERAL_TOKEN as u32)] = literal_flags;
480-
flags[NUM_TOKENS + (KEY_TOKEN as u32)] = key_token_flags;
470+
flags[NUM_TOKENS + NO_TOKEN] = no_token_flags;
471+
flags[NUM_TOKENS + BEGIN_OBJECT_TOKEN] = begin_object_flags;
472+
flags[NUM_TOKENS + END_OBJECT_TOKEN] = end_object_flags;
473+
flags[NUM_TOKENS + BEGIN_ARRAY_TOKEN] = begin_array_flags;
474+
flags[NUM_TOKENS + END_ARRAY_TOKEN] = end_array_flags;
475+
flags[NUM_TOKENS + KEY_SEPARATOR_TOKEN] = no_token_flags;
476+
flags[NUM_TOKENS + VALUE_SEPARATOR_TOKEN] = no_token_flags;
477+
flags[NUM_TOKENS + STRING_TOKEN] = string_flags;
478+
flags[NUM_TOKENS + NUMERIC_TOKEN] = numeric_flags;
479+
flags[NUM_TOKENS + LITERAL_TOKEN] = literal_flags;
480+
flags[NUM_TOKENS + KEY_TOKEN] = key_token_flags;
481481

482482
let mut result: [Field; NUM_TOKENS * 2] = [0; NUM_TOKENS * 2];
483-
for i in 0..(NUM_TOKENS as u32 * 2) {
483+
for i in 0..(NUM_TOKENS * 2) {
484484
result[i] = flags[i].to_field();
485485
}
486486
result

src/getters.nr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
9494
assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key");
9595

9696
let hasher: ByteHasher<MaxKeyFields> = ByteHasher {};
97-
let keyhash = hasher.get_keyhash_var(key.storage(), 0, key.len() as u32);
97+
let keyhash = hasher.get_keyhash_var(key.storage(), 0, key.len());
9898
let two_pow_216 = 0x100000000000000000000000000000000000000000000000000000000;
9999

100100
let keyhash = keyhash + self.root_id * two_pow_216;
@@ -147,7 +147,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
147147
assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key");
148148

149149
let hasher: ByteHasher<MaxKeyFields> = ByteHasher {};
150-
let keyhash = hasher.get_keyhash_var(key.storage(), 0, key.len() as u32);
150+
let keyhash = hasher.get_keyhash_var(key.storage(), 0, key.len());
151151
let two_pow_216 = 0x100000000000000000000000000000000000000000000000000000000;
152152

153153
let keyhash = keyhash + self.root_id * two_pow_216;
@@ -395,7 +395,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
395395
case 3: entry A > keyhash > entryB
396396
*/
397397
let hasher: ByteHasher<MaxKeyFields> = ByteHasher {};
398-
let keyhash = hasher.get_keyhash_var(key.storage(), 0, key.len() as u32);
398+
let keyhash = hasher.get_keyhash_var(key.storage(), 0, key.len());
399399

400400
let HASH_MAXIMUM = 0x1000000000000000000000000000000000000000000000000000000000000 - 1;
401401
let two_pow_216 = 0x100000000000000000000000000000000000000000000000000000000;

src/keyhash.nr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl<let KeyFields: u32> FieldHasher<KeyFields> {
1818
key_length: Field,
1919
) -> Field {
2020
let key_fields: [Field; KeyFields] = slice_fields(packed_fields, body_index, key_length);
21-
let hashed = poseidon::poseidon2::Poseidon2::hash(key_fields, KeyFields as u32);
21+
let hashed = poseidon::poseidon2::Poseidon2::hash(key_fields, KeyFields);
2222
slice_200_bits_from_field(hashed)
2323
}
2424
}
@@ -60,7 +60,7 @@ impl<let KeyFields: u32> ByteHasher<KeyFields> {
6060
key_fields[j] = limb;
6161
}
6262

63-
let hashed_full = poseidon::poseidon2::Poseidon2::hash(key_fields, KeyFields as u32);
63+
let hashed_full = poseidon::poseidon2::Poseidon2::hash(key_fields, KeyFields);
6464

6565
let mut r = slice_200_bits_from_field(hashed_full);
6666
r

0 commit comments

Comments
 (0)