Skip Menu |

This queue is for tickets about the String-Charcount CPAN distribution.

Report information
The Basics
Id: 5013
Status: resolved
Priority: 0/
Queue: String-Charcount

People
Owner: Nobody in particular
Requestors: rjbs [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: why pass scalar?
I think it's very odd that $string must be passed as a reference. It's pretty unnatural. This module might make more sense if it took a plain ol' string. Also, passing the hashref returned by $count back to &percentage is weird. Why not have percentage call count on its own. If you're concerned about optimization, let $count be passed optionally.
1st point: I enforced passing scalar as refs in case strings would become rather big; I am still unsure whether to switch to plain scalar dumping. 2nd point: This is a rather valuable advise; it will be changed until the next release. The extra passing, as you originated the source, has arisen from (pre?-)optimization.
From: rjbs [...] cpan.org
[SCHUBIGER - Fri Jan 23 12:38:12 2004]: Show quoted text
> 1st point: I enforced passing scalar as refs in case strings would > become rather big; I am still unsure whether to switch to plain > scalar dumping.
You're not necessarily saving anything. @_ contains aliases to the passed values, not copies, so if you create your character array with @array = split //, @_[0] then you gain nothing by passing a reference -- except for more confusing code. Show quoted text
> 2nd point: This is a rather valuable advise; it will be changed > until the next release. The extra passing, as you originated the > source, has arisen from (pre?-)optimization.
...and premature optimization is the root of all evil! :)
Update: Scalar ref passing removed and hashref passing to percentage() voluntary.