Skip to content

Commit

Permalink
Add more enum size specifiers
Browse files Browse the repository at this point in the history
To reduce memory usage
  • Loading branch information
cbjeukendrup committed Jan 11, 2025
1 parent fd07813 commit b65ab3f
Show file tree
Hide file tree
Showing 23 changed files with 70 additions and 70 deletions.
2 changes: 1 addition & 1 deletion src/engraving/dom/actionicon.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "engravingitem.h"

namespace mu::engraving {
enum class ActionIconType {
enum class ActionIconType : signed char {
UNDEFINED = -1,

ACCIACCATURA,
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/dom/beam.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class Factory;
class Skyline;
class System;
class Beam;
enum class ActionIconType;
enum class SpannerSegmentType;
enum class ActionIconType : signed char;
enum class SpannerSegmentType : char;

struct TremAnchor {
ChordRest* chord1 = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/beambase.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct BeamFragment {
double py2[2];
};

enum class ChordBeamAnchorType {
enum class ChordBeamAnchorType : char {
Start, End, Middle
};

Expand Down
4 changes: 2 additions & 2 deletions src/engraving/dom/engravingitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class StaffType;
// OffsetChange
//---------------------------------------------------------

enum class OffsetChange {
enum class OffsetChange : signed char {
RELATIVE_OFFSET = -1,
NONE = 0,
ABSOLUTE_OFFSET = 1
Expand Down Expand Up @@ -124,7 +124,7 @@ enum class ElementFlag {
typedef muse::Flags<ElementFlag> ElementFlags;
DECLARE_OPERATORS_FOR_FLAGS(ElementFlags)

enum class KerningType
enum class KerningType : char
{
KERNING,
NON_KERNING,
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/glissando.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
namespace mu::engraving {
class Glissando;
class Note;
enum class GlissandoType;
enum class GlissandoType : char;

//---------------------------------------------------------
// @@ GlissandoSegment
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/mcursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MasterScore;
class TDuration;
class TimeSig;
class Chord;
enum class Key;
enum class Key : signed char;

//---------------------------------------------------------
// MCursor
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/note.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Spanner;
class StaffType;
class StretchedBend;
class NoteEditData;
enum class AccidentalType;
enum class AccidentalType : unsigned char;

static constexpr int MAX_DOTS = 4;

Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/pitchspelling.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
namespace mu::engraving {
class MidiNote;
class Note;
enum class Key;
enum class Key : signed char;

const int INVALID_PITCH = -1;

Expand Down
6 changes: 3 additions & 3 deletions src/engraving/dom/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ struct NoteVal;
struct ShowAnchors;

enum class BeatType : char;
enum class Key;
enum class Key : signed char;
enum class HairpinType : signed char;
enum class SegmentType;
enum class OttavaType : char;
enum class Voicing : signed char;
enum class HDuration : signed char;
enum class AccidentalType;
enum class LayoutBreakType;
enum class AccidentalType : unsigned char;
enum class LayoutBreakType : char;

enum class LoopBoundaryType : signed char {
Unknown = -1,
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/staff.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Score;
class StaffType;
class TimeSig;

enum class Key;
enum class Key : signed char;

//---------------------------------------------------------
// Staff
Expand Down
22 changes: 11 additions & 11 deletions src/engraving/dom/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#pragma once

#include <unordered_set>
#include <set>

#include "global/containers.h"

Expand All @@ -34,7 +34,7 @@
namespace mu::engraving {
class EngravingItem;

enum class CommandType {
enum class CommandType : signed char {
Unknown = -1,

// Parts
Expand Down Expand Up @@ -148,7 +148,7 @@ enum class CommandType {
//---------------------------------------------------------
// NOTE: keep this in sync with accList array in accidentals.cpp

enum class AccidentalType {
enum class AccidentalType : unsigned char {
///.\{
NONE,
FLAT,
Expand Down Expand Up @@ -331,7 +331,7 @@ enum class AccidentalType {
// NoteType
//---------------------------------------------------------

enum class NoteType {
enum class NoteType : unsigned char {
///.\{
NORMAL = 0,
ACCIACCATURA = 0x1,
Expand All @@ -348,19 +348,19 @@ enum class NoteType {

constexpr NoteType operator|(NoteType t1, NoteType t2)
{
return static_cast<NoteType>(static_cast<int>(t1) | static_cast<int>(t2));
return static_cast<NoteType>(static_cast<unsigned char>(t1) | static_cast<unsigned char>(t2));
}

constexpr bool operator&(NoteType t1, NoteType t2)
{
return static_cast<int>(t1) & static_cast<int>(t2);
return static_cast<unsigned char>(t1) & static_cast<unsigned char>(t2);
}

//---------------------------------------------------------
// HarmonyType
//---------------------------------------------------------

enum class HarmonyType {
enum class HarmonyType : char {
///.\{
STANDARD,
ROMAN,
Expand All @@ -372,7 +372,7 @@ enum class HarmonyType {
// MMRestRangeBracketType
//---------------------------------------------------------

enum class MMRestRangeBracketType {
enum class MMRestRangeBracketType : char {
///.\{
BRACKETS, PARENTHESES, NONE
///\}
Expand Down Expand Up @@ -413,7 +413,7 @@ enum class SegmentType {
KeySigAnnounce = 0x1000,
TimeSigAnnounce = 0x2000,
//--
All = -1, ///< Includes all barline types
All = 0xffff, ///< Includes all barline types
/// Alias for `BeginBarLine | StartRepeatBarLine | BarLine | EndBarLine`
BarLineType = BeginBarLine | StartRepeatBarLine | BarLine | EndBarLine,
///\}
Expand Down Expand Up @@ -496,14 +496,14 @@ enum class TripletFeelType : char {
SCOTTISH_16TH
};

enum class GuitarBendType {
enum class GuitarBendType : char {
BEND,
PRE_BEND,
GRACE_NOTE_BEND,
SLIGHT_BEND,
};

enum class GuitarBendShowHoldLine {
enum class GuitarBendShowHoldLine : char {
AUTO,
SHOW,
HIDE,
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class System;
class Tuplet;
class Volta;

enum class Key;
enum class Key : signed char;

extern RectF handleRect(const PointF& pos);

Expand Down
2 changes: 1 addition & 1 deletion src/engraving/rendering/iscorerenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Harmony;

class Image;

enum class KerningType;
enum class KerningType : char;
class KeySig;

class LedgerLine;
Expand Down
8 changes: 4 additions & 4 deletions src/engraving/rendering/score/beamtremololayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ class Chord;
class ChordRest;
class Beam;
class TremoloTwoChord;
enum class ActionIconType;
enum class SpannerSegmentType;
enum class ChordBeamAnchorType;
enum class ActionIconType : signed char;
enum class SpannerSegmentType : char;
enum class ChordBeamAnchorType : char;
}

enum class SlopeConstraint
enum class SlopeConstraint : char
{
NO_CONSTRAINT,
FLAT,
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/rendering/score/horizontalspacing.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class Segment;
struct Spring;
class Measure;
class System;
enum class ElementType;
enum class KerningType;
enum class ElementType : unsigned char;
enum class KerningType : char;
}

namespace mu::engraving::rendering::score {
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/types/symid.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define MU_ENGRAVING_SYMID_H

namespace mu::engraving {
enum class SmuflAnchorId {
enum class SmuflAnchorId : char {
stemDownNW,
stemUpSE,
stemDownSW,
Expand Down
Loading

0 comments on commit b65ab3f

Please sign in to comment.