unnecessary MALLOC in nsLatin1Prober

RESOLVED WORKSFORME

Status

()

RESOLVED WORKSFORME
17 years ago
17 years ago

People

(Reporter: ftang, Assigned: shanjian)

Tracking

({intl})

Trunk
x86
Windows NT
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

17 years ago
in extensions/universalchardet/src/nsLatin1Prober.cpp
there are a unnecessary MALLOC

currently, nsLatin1Prober::HandleData call 
nsLatin1Prober::FilterWithEnglishLetters to filter out some data
 and nsLatin1Prober::FilterWithEnglishLetters will malloc
but, this is unnecessary
what we can do is to take out FilterWithEnglishLetters and implement the state
machine IN the for loop of nsLatin1Prober::HandleData

In other word, instead of (pseudo code)
nsLatin1Prober::HandleData( data)
{
 newdata = FilterWithEnglishLetters(data)
 for(newdata; newdata < newdataend; newdata++)
 {
   process every newdata
 }
 free newdata
}
FilterWithEnglishLetters(data)
{
  newdata = MALLOC
  for(data) 
  {
     if(xxx) 
        copy data to newdata
     else
        skip 
  }
}

change to
nsLatin1Prober::HandleData( data)
{
 for(data; data < dataend; data++)
 {
   if(xxx) 
   {
      process data
   } else {
      skip data
   }
 }
}

Comment 1

17 years ago
code issue, QA to yokoyama@netscape.com for now.
Keywords: intl
QA Contact: ruixu → yokoyama
(Assignee)

Comment 2

17 years ago
This latin1 prober is not a final solution. The final one should happen within
SingleCharGroupProber. I would prefer to keep this architecture. If latin1
prober is part of the group prober, filtering will happen in group level instead
of for each individual prober. That will speed up the whole process. 
Status: NEW → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.