Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#16896 closed Cleanup/optimization (needsinfo)

ComentDetailsForm.clean_comment calls lower() in each iteration

Reported by: gasull@… Owned by: nobody
Component: contrib.comments Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I would change this line from

bad_words = [w for w in settings.PROFANITIES_LIST if w in comment.lower()]

to

lowercased_comment = comment.lower()
bad_words = [w for w in settings.PROFANITIES_LIST if w in lowercased_comment]

.

This way lower() won't need to be run on each iteration.

Change History (3)

comment:1 by Carl Meyer, 13 years ago

Triage Stage: UnreviewedAccepted

Ugh - this code is still in Django? I think it's about time to deprecate PROFANITIES_LIST and COMMENTS_ALLOW_PROFANITIES (the latter doesn't even seem to be documented, but its default value is False - i.e. block profanities.)

Anyway, as long as we've got the code it may as well not be stupidly inefficient. Thanks for the report!

comment:2 by Alex Gaynor, 13 years ago

Resolution: needsinfo
Status: newclosed

I'm closign as needsinfo, unless someone has a profile showing that this is a significant portion of a real request, there's no point to have addition code churn. Plus, as Carl notes, this code really should be deprecated.

comment:3 by Luke Plant, 13 years ago

In 1.3 we said "No more naughty words" and waved off the Scunthorpe problem by setting PROFANITIES_LIST to an empty list by default, which is tantamount to deprecating the functionality. But technically we didn't deprecate the setting, and COMMENTS_ALLOW_PROFANITIES. We should do that for 1.4.

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