Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-09

Converting String to array of Char generates duplicate local var

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

cobines

Hello.

I have definitions:

PluginDir: packed array [0..Pred(16384)] of AnsiChar;
sName: AnsiString;

When I assign AnsiString to array of Char compiler generates code like this:

-4(%ebp) is source string
-17252(%ebp) is local temporary array
4(%ebx) is my destination array of char

# [411] PluginDir:= sName;
movl -4(%ebp),%ecx
leal -17252(%ebp),%eax
movl $16383,%edx
call fpc_ansistr_to_chararray
leal 4(%ebx),%edi
leal -17252(%ebp),%esi
cld
movl $4096,%ecx
rep
movsl

The result is copying data twice and as you see array is quite big. Is it not possible to write directly to 4(%ebx)?

FPC 2.7.1 i386-Linux

cobines