Opened 19 years ago

Closed 19 years ago

Last modified 17 years ago

#186 closed enhancement (fixed)

[patch] Refactor django/core/meta.py to eliminate duplicate code

Reported by: rmunn@… Owned by: Adrian Holovaty
Component: Metasystem Version:
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The function_get_list and function_get_iterator functions in django/core/meta.py are identical except for their return type. I propose refactoring them by making function_get_list into a simple wrapper around function_get_iterator.

Attachments (1)

refactor-function-get-list.patch (1.6 KB ) - added by rmunn@… 19 years ago.
Proposed patch to refactor function_get_list

Download all attachments as: .zip

Change History (4)

by rmunn@…, 19 years ago

Proposed patch to refactor function_get_list

comment:1 by rmunn@…, 19 years ago

The only difference between these two functions is that get_iterator calls cursor.fetchmany() at least once, and multiple times if necessary, until all rows have been returned; whereas get_list calls cursor.fetchall() exactly once.

If there is a database where fetchmany() incurs a significant performance penalty versus fetchall(), then it would be worth having two separate functions. But as it is, I see no benefit to the code duplication here.

comment:2 by rmunn@…, 19 years ago

Summary: Refactor django/core/meta.py to eliminate duplicate code[patch] Refactor django/core/meta.py to eliminate duplicate code

comment:3 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

(In [329]) Fixed #186 -- Refactored meta.py to remove duplicate code between function_get_list and function_get_iterator. Thanks, rmunn@…

Note: See TracTickets for help on using tickets.
Back to Top