Closed Bug 169912 Opened 22 years ago Closed 22 years ago

unnecessary MALLOC in nsLatin1Prober

Categories

(Core :: Internationalization, defect)

x86
Windows NT
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: ftang, Assigned: shanjian)

References

()

Details

(Keywords: intl)

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
   }
 }
}
code issue, QA to yokoyama@netscape.com for now.
Keywords: intl
QA Contact: ruixu → yokoyama
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
Closed: 22 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.