Skip to content

Commit

Permalink
Avoid second call to ippFindAttribute
Browse files Browse the repository at this point in the history
We already have the attr value.
  • Loading branch information
AZero13 committed Sep 13, 2024
1 parent 2dad30d commit b1e9881
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions scheduler/job.c
Original file line number Diff line number Diff line change
Expand Up @@ -1691,32 +1691,30 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */

cupsFileClose(fp);

/*
* Copy attribute data to the job object...
*/
/*
* Copy attribute data to the job object...
*/

if (!ippFindAttribute(job->attrs, "time-at-creation", IPP_TAG_INTEGER))
if ((job->state = ippFindAttribute(job->attrs, "job-state",
IPP_TAG_ENUM)) == NULL)
{
cupsdLogJob(job, CUPSD_LOG_ERROR,
"Missing or bad time-at-creation attribute in control file.");
"Missing or bad job-state attribute in control file.");
goto error;
}

if ((job->state = ippFindAttribute(job->attrs, "job-state",
IPP_TAG_ENUM)) == NULL)
if ((attr = ippFindAttribute(job->attrs, "time-at-creation", IPP_TAG_INTEGER)) == NULL)
{
cupsdLogJob(job, CUPSD_LOG_ERROR,
"Missing or bad job-state attribute in control file.");
"Missing or bad time-at-creation attribute in control file.");
goto error;
}

job->creation_time = attr->values[0].integer;
job->state_value = (ipp_jstate_t)job->state->values[0].integer;
job->file_time = 0;
job->history_time = 0;

if ((attr = ippFindAttribute(job->attrs, "time-at-creation", IPP_TAG_INTEGER)) != NULL)
job->creation_time = attr->values[0].integer;

if (job->state_value >= IPP_JSTATE_CANCELED && (attr = ippFindAttribute(job->attrs, "time-at-completed", IPP_TAG_INTEGER)) != NULL)
{
job->completed_time = attr->values[0].integer;
Expand Down

0 comments on commit b1e9881

Please sign in to comment.