[vlc-devel] commit: Drop a const on a static array and misc cleanup. (JP Dinger )

git version control git at videolan.org
Thu Sep 17 16:15:47 CEST 2009


vlc | branch: 1.0-bugfix | JP Dinger <jpd at videolan.org> | Fri Jul 31 18:26:16 2009 +0200| [596ea58679a329b4999d49f75dc1e5b279e136d7] | committer: Ilkka Ollakka 

Drop a const on a static array and misc cleanup.
(cherry picked from commit d0e62402b793afeb4b8fe0c0ea04ea1615d993d3)

Signed-off-by: Ilkka Ollakka <ileoo at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=596ea58679a329b4999d49f75dc1e5b279e136d7
---

 modules/access/dvb/scan.c |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/modules/access/dvb/scan.c b/modules/access/dvb/scan.c
index f088fb0..b35dd10 100644
--- a/modules/access/dvb/scan.c
+++ b/modules/access/dvb/scan.c
@@ -146,10 +146,9 @@ void scan_Clean( scan_t *p_scan )
 static int ScanDvbCNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double *pf_pos )
 {
     msg_Dbg( p_scan->p_obj, "Scan index %"PRId64, p_scan->i_index );
-    /* values from dvb-scan utils frequency-files, sorted
-     * by how often they appear, hopefully speedups finding
-     * services */
-    static int frequencies[] = {
+    /* Values taken from dvb-scan utils frequency-files, sorted by how
+     * often they appear. This hopefully speeds up finding services. */
+    static const unsigned short frequencies[] = {
      410, 426, 418, 394, 402, 362,
      370, 354, 346, 442, 434, 386,
      378, 450, 306, 162, 154, 474,
@@ -170,18 +169,15 @@ static int ScanDvbCNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
      163, 155, 147, 146, 143, 139,
      131, 123, 121
     };
+    enum { num_frequencies = (sizeof(frequencies)/sizeof(*frequencies)) };
 
-    if( p_scan->i_index < (sizeof(frequencies)/sizeof(int)) )
+    if( p_scan->i_index < num_frequencies )
     {
         p_cfg->i_frequency = 1000000 * ( frequencies[ p_scan->i_index ] );
+        *pf_pos = (double)p_scan->i_index / num_frequencies;
+        return VLC_SUCCESS;
     }
-    else
-    {
-        return VLC_EGENERIC;
-    }
-    *pf_pos = (double)p_scan->i_index / (sizeof(frequencies)/sizeof(int));
-    return VLC_SUCCESS;
-
+    return VLC_EGENERIC;
 }
 
 static int ScanDvbTNextExhaustive( scan_t *p_scan, scan_configuration_t *p_cfg, double *pf_pos )




More information about the vlc-devel mailing list