• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

polserver / polserver / 21100551564

17 Jan 2026 08:40PM UTC coverage: 60.504% (+0.01%) from 60.492%
21100551564

Pull #857

github

turleypol
fixed scope
Pull Request #857: ClangTidy readability-else-after-return

837 of 1874 new or added lines in 151 files covered. (44.66%)

48 existing lines in 26 files now uncovered.

44445 of 73458 relevant lines covered (60.5%)

515341.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.3
/pol-core/bscript/compiler/codegen/DataEmitter.cpp
1
#include "DataEmitter.h"
2

3
#include <algorithm>
4
#include <limits>
5
#include <stdexcept>
6

7
namespace Pol::Bscript::Compiler
8
{
9
DataEmitter::DataEmitter( DataSection& data_section ) : data_section( data_section ) {}
2,235✔
10

11
unsigned DataEmitter::append( double value )
443✔
12
{
13
  // The old compiler always appends doubles.  For parity,
14
  // we'll do the same here.
15
  return append( reinterpret_cast<const std::byte*>( &value ), sizeof value );
443✔
16
}
17

18
unsigned DataEmitter::append( int value )
17,503✔
19
{
20
  // The old compiler always appends integers.  For parity,
21
  // we'll do the same here.
22
  return append( reinterpret_cast<const std::byte*>( &value ), sizeof value );
17,503✔
23
}
24

25
unsigned DataEmitter::store( const std::string& s )
37,898✔
26
{
27
  return store( reinterpret_cast<const std::byte*>( s.c_str() ),
37,898✔
28
                static_cast<unsigned>( s.length() + 1 ) );
75,796✔
29
}
30

31
unsigned DataEmitter::store( const std::byte* data, size_t len )
40,133✔
32
{
33
  if ( auto existing = find( data, len ) )
40,133✔
34
    return existing;
21,125✔
35
  return append( data, len );
19,008✔
36
}
37

38
unsigned DataEmitter::append( const std::byte* data, size_t len )
37,058✔
39
{
40
  size_t position = data_section.size();
37,058✔
41
  if ( position + len > std::numeric_limits<unsigned>::max() )
37,058✔
42
  {
UNCOV
43
    throw std::runtime_error( "Data offset overflow" );
×
44
  }
45
  data_section.insert( data_section.end(), data, data + len );
37,058✔
46

47
  return static_cast<unsigned>( position );
37,058✔
48
}
49

50
unsigned DataEmitter::find( const std::byte* data, size_t len )
40,133✔
51
{
52
  if ( data_section.empty() )
40,133✔
53
    return 0;
2,235✔
54

55
  auto start = data_section.begin();
37,898✔
56
  ++start;  // offset=0 means no data, not data at offset 0
37,898✔
57
  auto itr = std::search( start, data_section.end(), data, data + len );
37,898✔
58
  if ( itr != data_section.end() )
37,898✔
59
    return static_cast<unsigned>( itr - data_section.begin() );
21,125✔
60
  return 0;
16,773✔
61
}
62

63
}  // namespace Pol::Bscript::Compiler
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc