@@ -308,7 +308,7 @@ func (cache *includeCache) WriteToFile() error {
308
308
return nil
309
309
}
310
310
311
- func (f * CppIncludesFinder ) findIncludesUntilDone (sourceFile SourceFile ) error {
311
+ func (f * CppIncludesFinder ) findIncludesUntilDone (sourceFile * SourceFile ) error {
312
312
sourcePath := sourceFile .SourcePath ()
313
313
targetFilePath := paths .NullPath ()
314
314
depPath := sourceFile .DepfilePath ()
@@ -441,23 +441,23 @@ type SourceFile struct {
441
441
RelativePath * paths.Path
442
442
}
443
443
444
- func (f SourceFile ) String () string {
444
+ func (f * SourceFile ) String () string {
445
445
return fmt .Sprintf ("Root: %s - Path: %s - BuildPath: %s" ,
446
446
f .SourceRoot , f .RelativePath , f .BuildRoot )
447
447
}
448
448
449
449
// MakeSourceFile creates a SourceFile containing the given source file path
450
450
// within the given sourceRoot. If srcPath is absolute it is transformed to
451
451
// relative to sourceRoot.
452
- func MakeSourceFile (sourceRoot , buildRoot , srcPath * paths.Path ) (SourceFile , error ) {
452
+ func MakeSourceFile (sourceRoot , buildRoot , srcPath * paths.Path ) (* SourceFile , error ) {
453
453
if srcPath .IsAbs () {
454
454
if relPath , err := sourceRoot .RelTo (srcPath ); err == nil {
455
455
srcPath = relPath
456
456
} else {
457
- return SourceFile {} , err
457
+ return nil , err
458
458
}
459
459
}
460
- return SourceFile {SourceRoot : sourceRoot , BuildRoot : buildRoot , RelativePath : srcPath }, nil
460
+ return & SourceFile {SourceRoot : sourceRoot , BuildRoot : buildRoot , RelativePath : srcPath }, nil
461
461
}
462
462
463
463
// SourcePath returns the path to the source file
@@ -475,22 +475,30 @@ func (f *SourceFile) DepfilePath() *paths.Path {
475
475
return f .BuildRoot .Join (f .RelativePath .String () + ".d" )
476
476
}
477
477
478
+ // Equals return true if the SourceFile equals to the SourceFile
479
+ // passed as parameter
480
+ func (f * SourceFile ) Equals (other * SourceFile ) bool {
481
+ return f .BuildRoot .EqualsTo (other .BuildRoot ) &&
482
+ f .SourceRoot .EqualsTo (other .SourceRoot ) &&
483
+ f .RelativePath .EqualsTo (other .RelativePath )
484
+ }
485
+
478
486
type UniqueSourceFileQueue struct {
479
- queue []SourceFile
487
+ queue []* SourceFile
480
488
curr int
481
489
}
482
490
483
491
func (q * UniqueSourceFileQueue ) Len () int {
484
492
return len (q .queue ) - q .curr
485
493
}
486
494
487
- func (q * UniqueSourceFileQueue ) Push (value SourceFile ) {
495
+ func (q * UniqueSourceFileQueue ) Push (value * SourceFile ) {
488
496
if ! q .Contains (value ) {
489
497
q .queue = append (q .queue , value )
490
498
}
491
499
}
492
500
493
- func (q * UniqueSourceFileQueue ) Pop () SourceFile {
501
+ func (q * UniqueSourceFileQueue ) Pop () * SourceFile {
494
502
res := q .queue [q .curr ]
495
503
q .curr ++
496
504
return res
@@ -500,11 +508,9 @@ func (q *UniqueSourceFileQueue) Empty() bool {
500
508
return q .Len () == 0
501
509
}
502
510
503
- func (q * UniqueSourceFileQueue ) Contains (target SourceFile ) bool {
511
+ func (q * UniqueSourceFileQueue ) Contains (target * SourceFile ) bool {
504
512
for _ , elem := range q .queue {
505
- if elem .BuildRoot .EqualsTo (target .BuildRoot ) &&
506
- elem .SourceRoot .EqualsTo (target .SourceRoot ) &&
507
- elem .RelativePath .EqualsTo (target .RelativePath ) {
513
+ if elem .Equals (target ) {
508
514
return true
509
515
}
510
516
}
0 commit comments