@@ -318,7 +318,7 @@ func (cache *includeCache) WriteToFile() error {
318
318
return nil
319
319
}
320
320
321
- func (f * CppIncludesFinder ) findIncludesUntilDone (sourceFile SourceFile ) error {
321
+ func (f * CppIncludesFinder ) findIncludesUntilDone (sourceFile * SourceFile ) error {
322
322
sourcePath := sourceFile .SourcePath ()
323
323
targetFilePath := paths .NullPath ()
324
324
depPath := sourceFile .DepfilePath ()
@@ -459,23 +459,23 @@ type SourceFile struct {
459
459
RelativePath * paths.Path
460
460
}
461
461
462
- func (f SourceFile ) String () string {
462
+ func (f * SourceFile ) String () string {
463
463
return fmt .Sprintf ("Root: %s - Path: %s - BuildPath: %s" ,
464
464
f .SourceRoot , f .RelativePath , f .BuildRoot )
465
465
}
466
466
467
467
// MakeSourceFile creates a SourceFile containing the given source file path
468
468
// within the given sourceRoot. If srcPath is absolute it is transformed to
469
469
// relative to sourceRoot.
470
- func MakeSourceFile (sourceRoot , buildRoot , srcPath * paths.Path ) (SourceFile , error ) {
470
+ func MakeSourceFile (sourceRoot , buildRoot , srcPath * paths.Path ) (* SourceFile , error ) {
471
471
if srcPath .IsAbs () {
472
472
if relPath , err := sourceRoot .RelTo (srcPath ); err == nil {
473
473
srcPath = relPath
474
474
} else {
475
- return SourceFile {} , err
475
+ return nil , err
476
476
}
477
477
}
478
- return SourceFile {SourceRoot : sourceRoot , BuildRoot : buildRoot , RelativePath : srcPath }, nil
478
+ return & SourceFile {SourceRoot : sourceRoot , BuildRoot : buildRoot , RelativePath : srcPath }, nil
479
479
}
480
480
481
481
// SourcePath returns the path to the source file
@@ -493,22 +493,30 @@ func (f *SourceFile) DepfilePath() *paths.Path {
493
493
return f .BuildRoot .Join (f .RelativePath .String () + ".d" )
494
494
}
495
495
496
+ // Equals return true if the SourceFile equals to the SourceFile
497
+ // passed as parameter
498
+ func (f * SourceFile ) Equals (other * SourceFile ) bool {
499
+ return f .BuildRoot .EqualsTo (other .BuildRoot ) &&
500
+ f .SourceRoot .EqualsTo (other .SourceRoot ) &&
501
+ f .RelativePath .EqualsTo (other .RelativePath )
502
+ }
503
+
496
504
type UniqueSourceFileQueue struct {
497
- queue []SourceFile
505
+ queue []* SourceFile
498
506
curr int
499
507
}
500
508
501
509
func (q * UniqueSourceFileQueue ) Len () int {
502
510
return len (q .queue ) - q .curr
503
511
}
504
512
505
- func (q * UniqueSourceFileQueue ) Push (value SourceFile ) {
513
+ func (q * UniqueSourceFileQueue ) Push (value * SourceFile ) {
506
514
if ! q .Contains (value ) {
507
515
q .queue = append (q .queue , value )
508
516
}
509
517
}
510
518
511
- func (q * UniqueSourceFileQueue ) Pop () SourceFile {
519
+ func (q * UniqueSourceFileQueue ) Pop () * SourceFile {
512
520
res := q .queue [q .curr ]
513
521
q .curr ++
514
522
return res
@@ -518,11 +526,9 @@ func (q *UniqueSourceFileQueue) Empty() bool {
518
526
return q .Len () == 0
519
527
}
520
528
521
- func (q * UniqueSourceFileQueue ) Contains (target SourceFile ) bool {
529
+ func (q * UniqueSourceFileQueue ) Contains (target * SourceFile ) bool {
522
530
for _ , elem := range q .queue {
523
- if elem .BuildRoot .EqualsTo (target .BuildRoot ) &&
524
- elem .SourceRoot .EqualsTo (target .SourceRoot ) &&
525
- elem .RelativePath .EqualsTo (target .RelativePath ) {
531
+ if elem .Equals (target ) {
526
532
return true
527
533
}
528
534
}
0 commit comments