Only copy sharename up from rap_to_pjobid
authorVolker Lendecke <vl@samba.org>
Sun, 1 Mar 2009 10:39:44 +0000 (11:39 +0100)
committerVolker Lendecke <vl@samba.org>
Sun, 1 Mar 2009 11:27:55 +0000 (12:27 +0100)
Why?? :-)

Another one of the little micro-optimizations that I just came across: If you
allocate a variable in a sub-block like the "fstring sharename" in
write_file(), gcc even with -O3 will allocate this variable unconditionally on
the stack at the beginning of the routine. So with eliminating this fstring we
cut 256 bytes of stack in a very hot code path writing to a file. It might make
us a bit more cache-friendly.

This would probably not be worth a second look if it involved larger code
changes, but this one was just too simple to let it pass :-)

source3/printing/printfsp.c
source3/printing/printing.c
source3/smbd/fileio.c

index b485711f910bd67203f80463e67c4780501c62ad..243b8ea03b7763538bcdb53427b1ca4daa624aba 100644 (file)
@@ -88,7 +88,6 @@ NTSTATUS print_fsp_open(struct smb_request *req, connection_struct *conn,
 void print_fsp_end(files_struct *fsp, enum file_close_type close_type)
 {
        uint32 jobid;
-       fstring sharename;
 
        if (fsp->fh->private_options & FILE_DELETE_ON_CLOSE) {
                /*
@@ -102,7 +101,7 @@ void print_fsp_end(files_struct *fsp, enum file_close_type close_type)
                string_free(&fsp->fsp_name);
        }
 
-       if (!rap_to_pjobid(fsp->rap_print_jobid, sharename, &jobid)) {
+       if (!rap_to_pjobid(fsp->rap_print_jobid, NULL, &jobid)) {
                DEBUG(3,("print_fsp_end: Unable to convert RAP jobid %u to print jobid.\n",
                        (unsigned int)fsp->rap_print_jobid ));
                return;
index 49bd5ac8ba829cfe9143fad3b28b994d91658353..fc3667ea3a959ff5a0041ed28ab6a4d99be34d56 100644 (file)
@@ -117,7 +117,9 @@ bool rap_to_pjobid(uint16 rap_jobid, fstring sharename, uint32 *pjobid)
        if ( data.dptr && data.dsize == sizeof(struct rap_jobid_key) )
        {
                struct rap_jobid_key *jinfo = (struct rap_jobid_key*)data.dptr;
-               fstrcpy( sharename, jinfo->sharename );
+               if (sharename != NULL) {
+                       fstrcpy( sharename, jinfo->sharename );
+               }
                *pjobid = jinfo->jobid;
                DEBUG(10,("rap_to_pjobid: jobid %u maps to RAP jobid %u\n",
                        (unsigned int)*pjobid, (unsigned int)rap_jobid));
index a9a97a2d14a133759dff5f54778c2dca769b2bd5..adf664b3960301da1713a81589b8b8e75a6f9307 100644 (file)
@@ -256,10 +256,9 @@ ssize_t write_file(struct smb_request *req,
        int write_path = -1;
 
        if (fsp->print_file) {
-               fstring sharename;
                uint32 jobid;
 
-               if (!rap_to_pjobid(fsp->rap_print_jobid, sharename, &jobid)) {
+               if (!rap_to_pjobid(fsp->rap_print_jobid, NULL, &jobid)) {
                        DEBUG(3,("write_file: Unable to map RAP jobid %u to jobid.\n",
                                                (unsigned int)fsp->rap_print_jobid ));
                        errno = EBADF;