Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#3293 closed Enhancement (fixed)

fggets() is overkill for parsing the blocklist

Reported by: charles Owned by: charles
Priority: Normal Milestone: 2.00
Component: libtransmission Version: 1.93
Severity: Normal Keywords: performance
Cc:

Description

fgets() is faster than fggets(), which uses fgetc() under the covers for every single character, and involves a malloc + free call for each line.

This is unnecessary -- we can preallocate a large enough buffer for any blocklist line. And if a line is longer than (to pick a number out of the air) 2048 characters, then line is corrupt and will be thrown away anyway, so in that situation fggets() still doesn't return any extra value.

Also this is the only place where fggets() is used in libtransmission, so we could also remove ggets.[ch].

Attachments (1)

fgets.diff (6.3 KB) - added by charles 11 years ago.

Download all attachments as: .zip

Change History (4)

Changed 11 years ago by charles

comment:1 Changed 11 years ago by charles

  • Milestone changed from 2.10 to 2.00
  • Status changed from new to assigned

comment:2 Changed 11 years ago by charles

  • Resolution set to fixed
  • Status changed from assigned to closed

patch applied to trunk by r10754.

comment:3 Changed 11 years ago by charles

  • Keywords performance added
Note: See TracTickets for help on using tickets.