Re: trivial refactoring of WaitOnLock
От | Neil Conway |
---|---|
Тема | Re: trivial refactoring of WaitOnLock |
Дата | |
Msg-id | 422EE68E.2030105@samurai.com обсуждение исходный текст |
Ответ на | Re: trivial refactoring of WaitOnLock (Russell Smith <mr-russ@pws.com.au>) |
Ответы |
Re: trivial refactoring of WaitOnLock
|
Список | pgsql-patches |
Russell Smith wrote: > *** 1083,1091 **** > locallock->lock, locallock->tag.mode); > > old_status = pstrdup(get_ps_display()); > ! new_status = (char *) palloc(strlen(old_status) + 10); > strcpy(new_status, old_status); > ! strcat(new_status, " waiting"); > set_ps_display(new_status); > > awaitedLock = locallock; > --- 1084,1093 ---- > locallock->lock, locallock->tag.mode); > > old_status = pstrdup(get_ps_display()); > ! len = strlen(old_status); > ! new_status = (char *) palloc(len + 9); > strcpy(new_status, old_status); > ! strcpy(&new_status[len], " waiting"); > set_ps_display(new_status); memcpy(new_status, old_status, len) would be faster yet. Which is what I originally implemented, and then decided the sprintf() was clearer (since performance isn't very important here). On reflection, memcpy() + strcpy() should be fine; I'll commit this tomorrow. -Neil
В списке pgsql-patches по дате отправления: