diff --git a/src/basic/basic_commands/cmd_let.s b/src/basic/basic_commands/cmd_let.s index 02c811ae..d395e4ed 100644 --- a/src/basic/basic_commands/cmd_let.s +++ b/src/basic/basic_commands/cmd_let.s @@ -259,24 +259,41 @@ cmd_let_assign_string_not_same: cmd_let_assign_string_not_text_area: - // Check if size of both strings equals and the old on is above FRETOP + // Check if the new string is a temporary one - if so, reuse alocation // XXX - // Check if new one is at least 3 bytes shorter and the old one is above FRETOP + // Check if the old string belongs to the string area (is above FRETOP) - // XXX + jsr varstr_cmp_fretop + bcc cmd_let_assign_string_no_optimizations - // Check if the new string is a temporary one - if so, reuse already done alocation + // FALLTROUGH - // XXX +cmd_let_assign_string_try_reuse: - // No special case optimization is possible - // Free the memory belonging to the old string + // Check if size of both strings equals + + lda DSCPNT+0 + cmp __FAC1 + bne cmd_let_assign_string_try_reuse_unsuccesful + + // Size of both string equals, the old one belongs to the string area - simply reuse it + + jmp helper_let_strvarcpy + +cmd_let_assign_string_try_reuse_unsuccesful: + // XXX consider another optimization first: parial memory reuse + + // No special case optimization is possible - but first get rid of the old string jsr varstr_free - // And allocate memory for the new string + // FALLTROUGH + +cmd_let_assign_string_no_optimizations: + + // Allocate memory for the new string lda __FAC1+0 ldy #$00 @@ -294,55 +311,6 @@ cmd_let_assign_string_not_text_area: jsr varstr_alloc - // Copy the string + // Copy the string and quit -#if CONFIG_MEMORY_MODEL_60K - - ldx #