Wiki

Ticket #133: numericFor-opt.patch

File numericFor-opt.patch, 2.0 KB (added by hopscc, 16 years ago)
  • Source/BackEndClr/SharpGenerator.cobra

     
    25402540            .stop.writeSharpDef(sw) 
    25412541            sw.write(';\n') 
    25422542 
     2543        isSimpleStep = false 
    25432544        if .step is nil 
    25442545            sharpStep = '1' 
     2546            isSimpleStep = true 
    25452547        else if .step inherits IntegerLit 
    25462548            sharpStep = (.step to IntegerLit).asSharp 
     2549            isSimpleStep = (.step to IntegerLit).value > 0 
    25472550        else 
    25482551            sw.write('[sharpType] [sharpStep] = ') 
    25492552            .step.writeSharpDef(sw) 
    25502553            sw.write(';\n') 
    25512554 
    2552         sw.write('int [sharpDir] = [sharpStep] < 0 ? -1 : +1;\n') 
     2555        if not isSimpleStep 
     2556            sw.write('int [sharpDir] = [sharpStep] < 0 ? -1 : +1;\n') 
    25532557 
    25542558        sw.write('for(') 
    25552559        if trackLocals 
    25562560            sw.write('CobraLangInternal.CobraImp.SetLocal("[.var.name]", [sharpVar] = [sharpStart])') 
    25572561        else 
    25582562            sw.write('[sharpVar] = [sharpStart]')        
    2559         sw.write('; ([sharpDir]==1) ? [sharpVar] < [sharpStop] : [sharpVar] > [sharpStop]; ') 
     2563        if isSimpleStep 
     2564            sw.write('; [sharpVar] < [sharpStop] ; ') 
     2565        else 
     2566            sw.write('; ([sharpDir]==1) ? [sharpVar] < [sharpStop] : [sharpVar] > [sharpStop]; ') 
    25602567        if trackLocals 
    25612568            sw.write('CobraLangInternal.CobraImp.SetLocal("[.var.name]", [sharpVar] += [sharpStep])') 
    25622569        else 
  • Developer/IntermediateReleaseNotes.text

     
    299299* Fixed: Cobra finds the definitions of identifiers in the parent namespaces of `used` namespaces, even when those parents themselves are not `used`. This leads to complications in practice when many namespaces are being used. ticket:128 
    300300 
    301301* Fixed: Literals outside type range give internal error message. ticket:131 
     302 
     303* Optimization: make new numeric For loop as fast as Old Numeric For Loop : ticket:133