Re: Strange inefficiency



Hi Elliot,

On Tue, 23 Jan 2001, Elliot Lee wrote:
> > 	The skel promptly tries to alloca 2.5Mb and has a fit.
> 
> That's definitely not the code that is doing it -
> sizeof((*buffer)._length) is going to be 4 bytes.

	Oh :-) sorry, quite right I cut and pasted the wrong block of
code, try this:

      {
	 guchar *_ORBIT_t;

	 _ORBIT_t =
	    alloca(sizeof((*buffer)._buffer[_ORBIT_tmpvar_0]) *
		   (*buffer)._length);
	    memcpy(_ORBIT_t, ((*buffer)._buffer),
		   sizeof((*buffer)._buffer[_ORBIT_tmpvar_0]) *
		   (*buffer)._length);
	 giop_message_buffer_append_mem(GIOP_MESSAGE_BUFFER
					(_ORBIT_send_buffer), (_ORBIT_t),
					sizeof((*buffer).
					       _buffer[_ORBIT_tmpvar_0]) *
					(*buffer)._length);
      }

	Then again; I'm fairly confused by what is achieved by:

	register CORBA_unsigned_long _ORBIT_tmpvar_0;
	... [ no assignment ]
	alloca(sizeof((*buffer)._buffer[_ORBIT_tmpvar_0]) *
                      (*buffer)._length);

	It would seem to me that the construct is not particularly useful;
since surely an array will always have the same element size regardless of
index - clearly it will be compiled to a constant. I imagine this just
makes the flow of the idl compiler easier to read.

	So; perhaps I'm wrong again; but it looks to me like the above
does:

	copy_on_stack = alloca (sizeof (_buffer[0]) * _length);
	memcpy (copy_on_stack, _buffer, sizeof (_buffer [0]) * _length);

	Which in this case is not going to work since _length ~= 2.5M.

	Regards,

		Michael.

-- 
 mmeeks gnu org  <><, Pseudo Engineer, itinerant idiot





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]